]> code.delx.au - pulseaudio/blobdiff - src/tests/interpol-test.c
merge 'lennart' branch back into trunk.
[pulseaudio] / src / tests / interpol-test.c
index 26a92dbf0b6582a34c9163c7cc856aa22ff2687a..85a509d4e18ba6af21fd202b3791a46fa92b154a 100644 (file)
@@ -1,20 +1,20 @@
 /* $Id$ */
 
 /***
-  This file is part of polypaudio.
-  polypaudio is free software; you can redistribute it and/or modify
+  This file is part of PulseAudio.
+
+  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,
   or (at your option) any later version.
-  polypaudio is distributed in the hope that it will be useful, but
+
+  PulseAudio is distributed in the hope that it will be useful, but
   WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
   General Public License for more details.
+
   You should have received a copy of the GNU Lesser General Public License
-  along with polypaudio; if not, write to the Free Software
+  along with PulseAudio; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
   USA.
 ***/
 #include <stdlib.h>
 #include <getopt.h>
 #include <math.h>
-#include <pthread.h>
 
-#include <polyp/polypaudio.h>
-#include <polyp/mainloop.h>
+#include <pulse/pulseaudio.h>
+#include <pulse/mainloop.h>
+
+#include <pulsecore/thread.h>
 
 static pa_context *context = NULL;
 static pa_stream *stream = NULL;
@@ -56,7 +57,7 @@ static void context_state_callback(pa_context *c, void *userdata) {
         case PA_CONTEXT_AUTHORIZING:
         case PA_CONTEXT_SETTING_NAME:
             break;
-        
+
         case PA_CONTEXT_READY: {
 
             static const pa_sample_spec ss = {
@@ -64,18 +65,18 @@ static void context_state_callback(pa_context *c, void *userdata) {
                 .rate = 44100,
                 .channels = 1
             };
-            
+
             fprintf(stderr, "Connection established.\n");
 
             stream = pa_stream_new(c, "interpol-test", &ss, NULL);
             assert(stream);
-            
+
             pa_stream_connect_playback(stream, NULL, NULL, PA_STREAM_INTERPOLATE_TIMING|PA_STREAM_AUTO_TIMING_UPDATE, NULL, NULL);
             pa_stream_set_write_callback(stream, stream_write_cb, NULL);
-                
+
             break;
         }
-            
+
         case PA_CONTEXT_TERMINATED:
             break;
 
@@ -107,19 +108,19 @@ int main(int argc, char *argv[]) {
     assert(r >= 0);
 
     pa_gettimeofday(&start);
-    
+
     pa_threaded_mainloop_start(m);
 
     for (k = 0; k < 5000; k++) {
         int success = 0, changed = 0;
         pa_usec_t t, rtc;
         struct timeval now, tv;
-        
+
         pa_threaded_mainloop_lock(m);
 
         if (stream) {
             const pa_timing_info *info;
-            
+
             if (pa_stream_get_time(stream, &t) >= 0)
                 success = 1;
 
@@ -129,23 +130,23 @@ int main(int argc, char *argv[]) {
                     last_info = info->timestamp;
                 }
         }
-        
+
         pa_threaded_mainloop_unlock(m);
-        
+
         if (success) {
             pa_gettimeofday(&now);
 
             rtc = pa_timeval_diff(&now, &start);
-            printf("%i\t%llu\t%llu\t%llu\t%llu\t%u\n", k, rtc, t, rtc-old_rtc, t-old_t, changed*2000000);
+            printf("%i\t%llu\t%llu\t%llu\t%llu\t%u\n", k, (unsigned long long) rtc, (unsigned long long) t, (unsigned long long) (rtc-old_rtc), (unsigned long long) (t-old_t), changed);
             old_t = t;
             old_rtc = rtc;
         }
 
-        /* Spin loop, eerks but normal usleep is just to badly grained */
+        /* Spin loop, ugly but normal usleep() is just too badly grained */
 
         tv = now;
         while (pa_timeval_diff(pa_gettimeofday(&now), &tv) < 1000)
-            pthread_yield();
+            pa_thread_yield();
     }
 
     if (m)
@@ -155,7 +156,7 @@ int main(int argc, char *argv[]) {
         pa_stream_disconnect(stream);
         pa_stream_unref(stream);
     }
-    
+
     if (context) {
         pa_context_disconnect(context);
         pa_context_unref(context);
@@ -163,6 +164,6 @@ int main(int argc, char *argv[]) {
 
     if (m)
         pa_threaded_mainloop_free(m);
-    
+
     return 0;
 }