From 3de129f3ac8dd6cf51178b266837db4d5e4a1215 Mon Sep 17 00:00:00 2001 From: Colin Guthrie Date: Mon, 4 Oct 2010 11:48:43 +0100 Subject: [PATCH] introspect: Include whether a stream is corked in the info callback. --- PROTOCOL | 7 +++++++ configure.ac | 2 +- src/pulse/introspect.c | 12 +++++++++--- src/pulse/introspect.h | 2 ++ src/pulsecore/protocol-native.c | 5 ++++- src/pulsecore/sink-input.c | 3 +++ src/pulsecore/source-output.c | 6 +++++- 7 files changed, 31 insertions(+), 6 deletions(-) diff --git a/PROTOCOL b/PROTOCOL index f180b96..3bd2894 100644 --- a/PROTOCOL +++ b/PROTOCOL @@ -200,3 +200,10 @@ new flag at end of CREATE_PLAYBACK_STREAM: new flag at end of CREATE_PLAYBACK_STREAM: bool passthrough + +## v19, implemented by >= 0.9.22 + +New proplist field for sink input, source output introspection opcodes and at the end: + + bool corked + diff --git a/configure.ac b/configure.ac index 4599128..7ab42dc 100644 --- a/configure.ac +++ b/configure.ac @@ -40,7 +40,7 @@ AC_SUBST(PA_MAJORMINORMICRO, pa_major.pa_minor.pa_micro) AC_SUBST(PACKAGE_URL, [http://pulseaudio.org/]) AC_SUBST(PA_API_VERSION, 12) -AC_SUBST(PA_PROTOCOL_VERSION, 18) +AC_SUBST(PA_PROTOCOL_VERSION, 19) # The stable ABI for client applications, for the version info x:y:z # always will hold y=z diff --git a/src/pulse/introspect.c b/src/pulse/introspect.c index 100413e..2a81788 100644 --- a/src/pulse/introspect.c +++ b/src/pulse/introspect.c @@ -996,7 +996,7 @@ static void context_get_sink_input_info_callback(pa_pdispatch *pd, uint32_t comm while (!pa_tagstruct_eof(t)) { pa_sink_input_info i; - pa_bool_t mute = FALSE; + pa_bool_t mute = FALSE, corked = FALSE; pa_zero(i); i.proplist = pa_proplist_new(); @@ -1014,7 +1014,8 @@ static void context_get_sink_input_info_callback(pa_pdispatch *pd, uint32_t comm pa_tagstruct_gets(t, &i.resample_method) < 0 || pa_tagstruct_gets(t, &i.driver) < 0 || (o->context->version >= 11 && pa_tagstruct_get_boolean(t, &mute) < 0) || - (o->context->version >= 13 && pa_tagstruct_get_proplist(t, i.proplist) < 0)) { + (o->context->version >= 13 && pa_tagstruct_get_proplist(t, i.proplist) < 0) || + (o->context->version >= 19 && pa_tagstruct_get_boolean(t, &corked) < 0)) { pa_context_fail(o->context, PA_ERR_PROTOCOL); pa_proplist_free(i.proplist); @@ -1022,6 +1023,7 @@ static void context_get_sink_input_info_callback(pa_pdispatch *pd, uint32_t comm } i.mute = (int) mute; + i.corked = (int) corked; if (o->callback) { pa_sink_input_info_cb_t cb = (pa_sink_input_info_cb_t) o->callback; @@ -1091,6 +1093,7 @@ static void context_get_source_output_info_callback(pa_pdispatch *pd, uint32_t c while (!pa_tagstruct_eof(t)) { pa_source_output_info i; + pa_bool_t corked = FALSE; pa_zero(i); i.proplist = pa_proplist_new(); @@ -1106,13 +1109,16 @@ static void context_get_source_output_info_callback(pa_pdispatch *pd, uint32_t c pa_tagstruct_get_usec(t, &i.source_usec) < 0 || pa_tagstruct_gets(t, &i.resample_method) < 0 || pa_tagstruct_gets(t, &i.driver) < 0 || - (o->context->version >= 13 && pa_tagstruct_get_proplist(t, i.proplist) < 0)) { + (o->context->version >= 13 && pa_tagstruct_get_proplist(t, i.proplist) < 0) || + (o->context->version >= 19 && pa_tagstruct_get_boolean(t, &corked) < 0)) { pa_context_fail(o->context, PA_ERR_PROTOCOL); pa_proplist_free(i.proplist); goto finish; } + i.corked = (int) corked; + if (o->callback) { pa_source_output_info_cb_t cb = (pa_source_output_info_cb_t) o->callback; cb(o->context, &i, 0, o->userdata); diff --git a/src/pulse/introspect.h b/src/pulse/introspect.h index f9d22b2..d4107de 100644 --- a/src/pulse/introspect.h +++ b/src/pulse/introspect.h @@ -500,6 +500,7 @@ typedef struct pa_sink_input_info { const char *driver; /**< Driver name */ int mute; /**< Stream muted \since 0.9.7 */ pa_proplist *proplist; /**< Property list \since 0.9.11 */ + int corked; /**< Stream corked \since 0.9.22 */ } pa_sink_input_info; /** Callback prototype for pa_context_get_sink_input_info() and friends*/ @@ -546,6 +547,7 @@ typedef struct pa_source_output_info { const char *resample_method; /**< The resampling method used by this source output. */ const char *driver; /**< Driver name */ pa_proplist *proplist; /**< Property list \since 0.9.11 */ + int corked; /**< Stream corked \since 0.9.22 */ } pa_source_output_info; /** Callback prototype for pa_context_get_source_output_info() and friends*/ diff --git a/src/pulsecore/protocol-native.c b/src/pulsecore/protocol-native.c index adb995f..85245a9 100644 --- a/src/pulsecore/protocol-native.c +++ b/src/pulsecore/protocol-native.c @@ -3079,6 +3079,8 @@ static void sink_input_fill_tagstruct(pa_native_connection *c, pa_tagstruct *t, pa_tagstruct_put_boolean(t, pa_sink_input_get_mute(s)); if (c->version >= 13) pa_tagstruct_put_proplist(t, s->proplist); + if (c->version >= 19) + pa_tagstruct_put_boolean(t, (pa_sink_input_get_state(s) == PA_SINK_INPUT_CORKED)); } static void source_output_fill_tagstruct(pa_native_connection *c, pa_tagstruct *t, pa_source_output *s) { @@ -3101,9 +3103,10 @@ static void source_output_fill_tagstruct(pa_native_connection *c, pa_tagstruct * pa_tagstruct_put_usec(t, source_latency); pa_tagstruct_puts(t, pa_resample_method_to_string(pa_source_output_get_resample_method(s))); pa_tagstruct_puts(t, s->driver); - if (c->version >= 13) pa_tagstruct_put_proplist(t, s->proplist); + if (c->version >= 19) + pa_tagstruct_put_boolean(t, (pa_source_output_get_state(s) == PA_SOURCE_OUTPUT_CORKED)); } static void scache_fill_tagstruct(pa_native_connection *c, pa_tagstruct *t, pa_scache_entry *e) { diff --git a/src/pulsecore/sink-input.c b/src/pulsecore/sink-input.c index 190e2d0..fe840b8 100644 --- a/src/pulsecore/sink-input.c +++ b/src/pulsecore/sink-input.c @@ -470,6 +470,9 @@ static void sink_input_set_state(pa_sink_input *i, pa_sink_input_state_t state) for (ssync = i->sync_next; ssync; ssync = ssync->sync_next) pa_hook_fire(&i->core->hooks[PA_CORE_HOOK_SINK_INPUT_STATE_CHANGED], ssync); + + if (PA_SINK_INPUT_IS_LINKED(state)) + pa_subscription_post(i->core, PA_SUBSCRIPTION_EVENT_SINK_INPUT|PA_SUBSCRIPTION_EVENT_CHANGE, i->index); } pa_sink_update_status(i->sink); diff --git a/src/pulsecore/source-output.c b/src/pulsecore/source-output.c index 57ccc06..88731e7 100644 --- a/src/pulsecore/source-output.c +++ b/src/pulsecore/source-output.c @@ -291,9 +291,13 @@ static void source_output_set_state(pa_source_output *o, pa_source_output_state_ update_n_corked(o, state); o->state = state; - if (state != PA_SOURCE_OUTPUT_UNLINKED) + if (state != PA_SOURCE_OUTPUT_UNLINKED) { pa_hook_fire(&o->core->hooks[PA_CORE_HOOK_SOURCE_OUTPUT_STATE_CHANGED], o); + if (PA_SOURCE_OUTPUT_IS_LINKED(state)) + pa_subscription_post(o->core, PA_SUBSCRIPTION_EVENT_SOURCE_OUTPUT|PA_SUBSCRIPTION_EVENT_CHANGE, o->index); + } + pa_source_update_status(o->source); } -- 2.7.4