From 9362edf3ec1c7b4fa8379c449bffc922559f2b86 Mon Sep 17 00:00:00 2001 From: Janos Kovacs Date: Thu, 3 Oct 2013 17:06:20 +0300 Subject: [PATCH] stream-state: mute streams instead corking them except at start Change-Id: I4d62533b4cbcf3930a17cfa8522f5a70bf48c393 --- murphy/murphyif.c | 2 +- murphy/stream-state.c | 41 +++++++++++++++++++++++++++++------------ 2 files changed, 30 insertions(+), 13 deletions(-) diff --git a/murphy/murphyif.c b/murphy/murphyif.c index 9c36cc3..7d0214f 100644 --- a/murphy/murphyif.c +++ b/murphy/murphyif.c @@ -1867,7 +1867,7 @@ static void node_enforce_resource_policy(struct userdata *u, if (pa_streq(rset->policy, "relaxed")) req = PA_STREAM_RUN; else if (pa_streq(rset->policy, "strict")) { - if (rset->state == RSET_RELEASE) + if (rset->state == RSET_RELEASE && rset->autorel) req = PA_STREAM_KILL; else { if (rset->grant) diff --git a/murphy/stream-state.c b/murphy/stream-state.c index 5453448..4990079 100644 --- a/murphy/stream-state.c +++ b/murphy/stream-state.c @@ -144,6 +144,8 @@ static void sink_input_block(pa_sink_input *sinp, pa_bool_t block) { const char *event; pa_proplist *pl; + bool block_by_mute; + bool muted, corked; pa_assert(sinp); @@ -154,22 +156,37 @@ static void sink_input_block(pa_sink_input *sinp, pa_bool_t block) sinp->flags |= flag_mask; } - if (( sinp->corked_internal && !block) || - (!sinp->corked_internal && block) ) - { - pa_sink_input_cork_internal(sinp, block); + muted = pa_sink_input_get_mute(sinp); + corked = (sinp->flags & PA_SINK_INPUT_START_CORKED); - if (sinp->send_event) { - if (block) - event = PA_STREAM_EVENT_REQUEST_CORK; - else - event = PA_STREAM_EVENT_REQUEST_UNCORK; + if (corked && !block) + sinp->flags &= ~PA_SINK_INPUT_START_CORKED; - pl = pa_proplist_new(); + block_by_mute = !corked; - sinp->send_event(sinp, event, pl); + pa_log_debug("%sblock by %s", block ? "":"un", + block_by_mute ? "muting":"corking"); - pa_proplist_free(pl); + if (block_by_mute) { + if ((muted && !block) || (!muted && block)) + pa_sink_input_set_mute(sinp, block, FALSE); + } + else { + if ((corked && !block) || (!corked && block)) { + pa_sink_input_cork_internal(sinp, block); + + if (sinp->send_event) { + if (block) + event = PA_STREAM_EVENT_REQUEST_CORK; + else + event = PA_STREAM_EVENT_REQUEST_UNCORK; + + pl = pa_proplist_new(); + + sinp->send_event(sinp, event, pl); + + pa_proplist_free(pl); + } } } } -- 2.7.4