[pulseaudio-discuss] [PATCH] pacat: make pacat respond to cork/uncork events

Lu Guanqun guanqun.lu at intel.com
Mon Aug 22 23:18:22 PDT 2011


Pacat remembers the number of cork requests, and then cork/uncork the stream
accordingly.

With this change, it makes below test script work correctly:

	pacat -p --property=media.role="music" <long-sound> &
	sleep 2
	pacat -p --property=media.role="phone" <short-sound>
	wait

Signed-off-by: Lu Guanqun <guanqun.lu at intel.com>
---
 src/utils/pacat.c |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/src/utils/pacat.c b/src/utils/pacat.c
index f687402..2568db5 100644
--- a/src/utils/pacat.c
+++ b/src/utils/pacat.c
@@ -91,6 +91,8 @@ static int32_t latency_msec = 0, process_time_msec = 0;
 static pa_bool_t raw = TRUE;
 static int file_format = -1;
 
+static int cork_requests = 0;
+
 /* A shortcut for terminating the application */
 static void quit(int ret) {
     pa_assert(mainloop_api);
@@ -408,6 +410,15 @@ static void stream_event_callback(pa_stream *s, const char *name, pa_proplist *p
 
     t = pa_proplist_to_string_sep(pl, ", ");
     pa_log("Got event '%s', properties '%s'", name, t);
+
+    if (pa_streq(name, PA_STREAM_EVENT_REQUEST_CORK)) {
+        cork_requests++;
+        pa_operation_unref(pa_stream_cork(s, !!cork_requests, NULL, NULL));
+    } else if (pa_streq(name, PA_STREAM_EVENT_REQUEST_UNCORK)) {
+        cork_requests--;
+        pa_operation_unref(pa_stream_cork(s, !!cork_requests, NULL, NULL));
+    }
+
     pa_xfree(t);
 }
 



More information about the pulseaudio-discuss mailing list