PulseAudio is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
- by the Free Software Foundation; either version 2 of the License,
+ by the Free Software Foundation; either version 2.1 of the License,
or (at your option) any later version.
PulseAudio is distributed in the hope that it will be useful, but
#endif
#include <signal.h>
-#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
-#include <getopt.h>
#include <math.h>
#include <pulse/pulseaudio.h>
static const pa_buffer_attr buffer_attr = {
.maxlength = SAMPLE_HZ*sizeof(float)*NSTREAMS, /* exactly space for the entire play time */
- .tlength = 0,
- .prebuf = 0, /* Setting prebuf to 0 guarantees us the the streams will run synchronously, no matter what */
- .minreq = 0
+ .tlength = (uint32_t) -1,
+ .prebuf = 0, /* Setting prebuf to 0 guarantees us the streams will run synchronously, no matter what */
+ .minreq = (uint32_t) -1,
+ .fragsize = 0
};
static void nop_free_cb(void *p) {}
fprintf(stderr, "Writing data to stream %i.\n", i);
- r = pa_stream_write(s, data, sizeof(data), nop_free_cb, sizeof(data) * i, PA_SEEK_ABSOLUTE);
+ r = pa_stream_write(s, data, sizeof(data), nop_free_cb, (int64_t) sizeof(data) * (int64_t) i, PA_SEEK_ABSOLUTE);
assert(r == 0);
/* Be notified when this stream is drained */
pa_context_set_state_callback(context, context_state_callback, NULL);
- pa_context_connect(context, NULL, 0, NULL);
+ /* Connect the context */
+ if (pa_context_connect(context, NULL, 0, NULL) < 0) {
+ fprintf(stderr, "pa_context_connect() failed.\n");
+ goto quit;
+ }
if (pa_mainloop_run(m, &ret) < 0)
fprintf(stderr, "pa_mainloop_run() failed.\n");
+quit:
pa_context_unref(context);
for (i = 0; i < NSTREAMS; i++)