]> code.delx.au - pulseaudio/blobdiff - src/tests/sync-playback.c
fix the ever-popular 'the the' typo
[pulseaudio] / src / tests / sync-playback.c
index 7ab3a25ce941133cb20731003e4654c98adafa86..df1fa4534c7c491e18dffc371dba39018faf4185 100644 (file)
@@ -3,7 +3,7 @@
 
   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>
@@ -54,9 +52,10 @@ static const pa_sample_spec sample_spec = {
 
 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) {}
@@ -88,7 +87,7 @@ static void stream_state_callback(pa_stream *s, void *userdata) {
 
             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 */
@@ -173,11 +172,16 @@ int main(int argc, char *argv[]) {
 
     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++)