From: Mikel Astiz <mikel.astiz@xxxxxxxxxxxx> The initial state of a sink or source might not necessarily be IDLE, because sometimes it might be suspended from the very beginning. --- src/pulsecore/sink.c | 7 +++++-- src/pulsecore/sink.h | 2 ++ src/pulsecore/source.c | 7 +++++-- src/pulsecore/source.h | 2 ++ 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/pulsecore/sink.c b/src/pulsecore/sink.c index 3d72f55..237b859 100644 --- a/src/pulsecore/sink.c +++ b/src/pulsecore/sink.c @@ -248,7 +248,7 @@ pa_sink* pa_sink_new( s->state = PA_SINK_INIT; s->flags = flags; s->priority = 0; - s->suspend_cause = 0; + s->suspend_cause = data->suspend_cause; pa_sink_set_mixer_dirty(s, FALSE); s->name = pa_xstrdup(name); s->proplist = pa_proplist_copy(data->proplist); @@ -650,7 +650,10 @@ void pa_sink_put(pa_sink* s) { pa_assert(s->monitor_source->thread_info.min_latency == s->thread_info.min_latency); pa_assert(s->monitor_source->thread_info.max_latency == s->thread_info.max_latency); - pa_assert_se(sink_set_state(s, PA_SINK_IDLE) == 0); + if (s->suspend_cause) + pa_assert_se(sink_set_state(s, PA_SINK_SUSPENDED) == 0); + else + pa_assert_se(sink_set_state(s, PA_SINK_IDLE) == 0); pa_source_put(s->monitor_source); diff --git a/src/pulsecore/sink.h b/src/pulsecore/sink.h index 2c52348..fcda5ef 100644 --- a/src/pulsecore/sink.h +++ b/src/pulsecore/sink.h @@ -328,6 +328,8 @@ typedef enum pa_sink_message { } pa_sink_message_t; typedef struct pa_sink_new_data { + pa_suspend_cause_t suspend_cause; + char *name; pa_proplist *proplist; diff --git a/src/pulsecore/source.c b/src/pulsecore/source.c index cefddae..7af86f5 100644 --- a/src/pulsecore/source.c +++ b/src/pulsecore/source.c @@ -235,7 +235,7 @@ pa_source* pa_source_new( s->state = PA_SOURCE_INIT; s->flags = flags; s->priority = 0; - s->suspend_cause = 0; + s->suspend_cause = data->suspend_cause; pa_source_set_mixer_dirty(s, FALSE); s->name = pa_xstrdup(name); s->proplist = pa_proplist_copy(data->proplist); @@ -595,7 +595,10 @@ void pa_source_put(pa_source *s) { pa_assert(!(s->flags & PA_SOURCE_DECIBEL_VOLUME) || s->n_volume_steps == PA_VOLUME_NORM+1); pa_assert(!(s->flags & PA_SOURCE_DYNAMIC_LATENCY) == (s->thread_info.fixed_latency != 0)); - pa_assert_se(source_set_state(s, PA_SOURCE_IDLE) == 0); + if (s->suspend_cause) + pa_assert_se(source_set_state(s, PA_SOURCE_SUSPENDED) == 0); + else + pa_assert_se(source_set_state(s, PA_SOURCE_IDLE) == 0); pa_subscription_post(s->core, PA_SUBSCRIPTION_EVENT_SOURCE | PA_SUBSCRIPTION_EVENT_NEW, s->index); pa_hook_fire(&s->core->hooks[PA_CORE_HOOK_SOURCE_PUT], s); diff --git a/src/pulsecore/source.h b/src/pulsecore/source.h index dd1e09b..224155b 100644 --- a/src/pulsecore/source.h +++ b/src/pulsecore/source.h @@ -265,6 +265,8 @@ typedef enum pa_source_message { } pa_source_message_t; typedef struct pa_source_new_data { + pa_suspend_cause_t suspend_cause; + char *name; pa_proplist *proplist; -- 1.7.7.6