[pulseaudio-commits] r2436 - /branches/glitch-free/src/utils/pacat.c

svnmailer-noreply at 0pointer.de svnmailer-noreply at 0pointer.de
Thu May 15 15:22:43 PDT 2008


Author: lennart
Date: Fri May 16 00:22:41 2008
New Revision: 2436

URL: http://0pointer.de/cgi-bin/viewcvs.cgi?rev=2436&root=pulseaudio&view=rev
Log:
Print message when stream started playback, use terminal sequence to clear line when printing that message

Modified:
    branches/glitch-free/src/utils/pacat.c

Modified: branches/glitch-free/src/utils/pacat.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/glitch-free/src/utils/pacat.c?rev=2436&root=pulseaudio&r1=2435&r2=2436&view=diff
==============================================================================
--- branches/glitch-free/src/utils/pacat.c (original)
+++ branches/glitch-free/src/utils/pacat.c Fri May 16 00:22:41 2008
@@ -44,6 +44,8 @@
 #error Invalid PulseAudio API version
 #endif
 
+#define CLEAR_LINE "\x1B[K"
+
 static enum { RECORD, PLAYBACK } mode = PLAYBACK;
 
 static pa_context *context = NULL;
@@ -206,29 +208,38 @@
 
     if (verbose) {
         if (pa_stream_is_suspended(s))
-            fprintf(stderr, "Stream device suspended.\n");
+            fprintf(stderr, "Stream device suspended." CLEAR_LINE " \n");
         else
-            fprintf(stderr, "Stream device resumed.\n");
+            fprintf(stderr, "Stream device resumed." CLEAR_LINE " \n");
     }
 }
 
 static void stream_underflow_callback(pa_stream *s, void *userdata) {
     assert(s);
 
-    fprintf(stderr, "Underrun.\n");
+    if (verbose)
+        fprintf(stderr, "Stream underrun." CLEAR_LINE " \n");
 }
 
 static void stream_overflow_callback(pa_stream *s, void *userdata) {
     assert(s);
 
-    fprintf(stderr, "Overrun.\n");
+    if (verbose)
+        fprintf(stderr, "Stream overrun." CLEAR_LINE " \n");
+}
+
+static void stream_started_callback(pa_stream *s, void *userdata) {
+    assert(s);
+
+    if (verbose)
+        fprintf(stderr, "Stream started." CLEAR_LINE " \n");
 }
 
 static void stream_moved_callback(pa_stream *s, void *userdata) {
     assert(s);
 
     if (verbose)
-        fprintf(stderr, "Stream moved to device %s (%u, %ssuspended).\n", pa_stream_get_device_name(s), pa_stream_get_device_index(s), pa_stream_is_suspended(s) ? "" : "not ");
+        fprintf(stderr, "Stream moved to device %s (%u, %ssuspended)." CLEAR_LINE " \n", pa_stream_get_device_name(s), pa_stream_get_device_index(s), pa_stream_is_suspended(s) ? "" : "not ");
 }
 
 /* This is called whenever the context status changes */
@@ -249,7 +260,7 @@
             assert(!stream);
 
             if (verbose)
-                fprintf(stderr, "Connection established.\n");
+                fprintf(stderr, "Connection established." CLEAR_LINE " \n");
 
             if (!(stream = pa_stream_new(c, stream_name, &sample_spec, channel_map_set ? &channel_map : NULL))) {
                 fprintf(stderr, "pa_stream_new() failed: %s\n", pa_strerror(pa_context_errno(c)));
@@ -263,6 +274,7 @@
             pa_stream_set_moved_callback(stream, stream_moved_callback, NULL);
             pa_stream_set_underflow_callback(stream, stream_underflow_callback, NULL);
             pa_stream_set_overflow_callback(stream, stream_overflow_callback, NULL);
+            pa_stream_set_started_callback(stream, stream_started_callback, NULL);
 
             if (latency > 0) {
                 memset(&buffer_attr, 0, sizeof(buffer_attr));




More information about the pulseaudio-commits mailing list