From 61b07768c2f7fcc38a32ba31db837a57335ed664 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 7 Apr 2009 00:46:20 +0200 Subject: add suspend_within_thread() callbacks to pa_sink_input/pa_source_output --- src/pulsecore/source.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'src/pulsecore/source.c') diff --git a/src/pulsecore/source.c b/src/pulsecore/source.c index 252e23ab..b85d6e12 100644 --- a/src/pulsecore/source.c +++ b/src/pulsecore/source.c @@ -933,9 +933,26 @@ int pa_source_process_msg(pa_msgobject *object, int code, void *userdata, int64_ case PA_SOURCE_MESSAGE_GET_MUTE: return 0; - case PA_SOURCE_MESSAGE_SET_STATE: + case PA_SOURCE_MESSAGE_SET_STATE: { + + pa_bool_t suspend_change = + (s->thread_info.state == PA_SOURCE_SUSPENDED && PA_SOURCE_IS_OPENED(PA_PTR_TO_UINT(userdata))) || + (PA_SOURCE_IS_OPENED(s->thread_info.state) && PA_PTR_TO_UINT(userdata) == PA_SOURCE_SUSPENDED); + s->thread_info.state = PA_PTR_TO_UINT(userdata); + + if (suspend_change) { + pa_source_output *o; + void *state = NULL; + + while ((o = pa_hashmap_iterate(s->thread_info.outputs, &state, NULL))) + if (o->suspend_within_thread) + o->suspend_within_thread(o, s->thread_info.state == PA_SOURCE_SUSPENDED); + } + + return 0; + } case PA_SOURCE_MESSAGE_DETACH: @@ -1217,7 +1234,7 @@ void pa_source_get_latency_range(pa_source *s, pa_usec_t *min_latency, pa_usec_t } } -/* Called from IO thread, and from main thread before pa_sink_put() is called */ +/* Called from IO thread, and from main thread before pa_source_put() is called */ void pa_source_set_latency_range_within_thread(pa_source *s, pa_usec_t min_latency, pa_usec_t max_latency) { void *state = NULL; -- cgit