From: Sangchul Lee Date: Mon, 28 Dec 2020 08:56:16 +0000 (+0900) Subject: stream-manager: Revise conditions to invoke ducking state changed signal X-Git-Tag: submit/tizen/20201229.083746^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=54a2c387877a7e71bb2cada016369c8f25afa74b;p=platform%2Fcore%2Fmultimedia%2Fpulseaudio-modules-tizen.git stream-manager: Revise conditions to invoke ducking state changed signal In sink_input_ramp_finish_cb(), it is fixed to send the signal only if the previous state of stream ducking is DUCKING or UNDUCKING. Some logs are revised for easy debugging. [Version] 13.0.43 [Issue Type] Improvement Change-Id: Ib857d6146afe3279436fa155bf18b0d45e9d1909 Signed-off-by: Sangchul Lee --- diff --git a/packaging/pulseaudio-modules-tizen.spec b/packaging/pulseaudio-modules-tizen.spec index e301cd3..c99a785 100644 --- a/packaging/pulseaudio-modules-tizen.spec +++ b/packaging/pulseaudio-modules-tizen.spec @@ -1,6 +1,6 @@ Name: pulseaudio-modules-tizen Summary: Pulseaudio modules for Tizen -Version: 13.0.42 +Version: 13.0.43 Release: 0 Group: Multimedia/Audio License: LGPL-2.1+ diff --git a/src/stream-manager-dbus.c b/src/stream-manager-dbus.c index d81d157..3545cd1 100644 --- a/src/stream-manager-dbus.c +++ b/src/stream-manager-dbus.c @@ -2110,8 +2110,8 @@ static void handle_activate_ducking(DBusConnection *conn, DBusMessage *msg, void if (enable) { pa_idxset_put(sd->idx_ducking_streams, (void *)i, NULL); - pa_log_error("ducking: add volume_ramp factor, key[%s], set_vol[%u] to stream[idx:%u]", - sd->vol_key, sd->set_vol, i->index); + pa_log_error("ducking: add volume_ramp factor, key[%s], set_vol[%u] to stream[idx:%u, state:%u]", + sd->vol_key, sd->set_vol, i->index, i->state); pa_cvolume_ramp_set(&vol_ramp, i->volume.channels, PA_VOLUME_RAMP_TYPE_LINEAR, (long)duration, sd->set_vol); @@ -2124,8 +2124,8 @@ static void handle_activate_ducking(DBusConnection *conn, DBusMessage *msg, void pa_sink_input_add_volume_ramp_factor(i, sd->vol_key, &vol_ramp, true); } } else { - pa_log_error("unducking: remove volume(ramp) factor, key[%s] from stream[idx:%u]", - sd->vol_key, i->index); + pa_log_error("unducking: remove volume(ramp) factor, key[%s] from stream[idx:%u, state:%u]", + sd->vol_key, i->index, i->state); pa_sink_input_remove_volume_factor(i, sd->vol_key); pa_sink_input_remove_volume_ramp_factor(i, sd->vol_key, true); @@ -2137,7 +2137,7 @@ static void handle_activate_ducking(DBusConnection *conn, DBusMessage *msg, void memset(&sd->vol_key, 0, sizeof(sd->vol_key)); } - pa_log_info("ducking stream count[%p,%d]", sd, sd->ducking_stream_count); + pa_log_info("stream ducking[%p, ducking_stream_count:%d]", sd, sd->ducking_stream_count); _ACTIVATE_DUCKING_DONE: pa_dbus_send_basic_value_reply(conn, msg, DBUS_TYPE_STRING, &stream_manager_dbus_ret_str[ret_msg]); diff --git a/src/stream-manager.c b/src/stream-manager.c index 4c12613..0ce45e2 100644 --- a/src/stream-manager.c +++ b/src/stream-manager.c @@ -2593,9 +2593,7 @@ static pa_hook_result_t sink_input_move_finish_cb(pa_core *core, pa_sink_input * } static pa_hook_result_t sink_input_ramp_finish_cb(pa_core *core, pa_sink_input *i, pa_stream_manager *m) { - stream_ducking *sd = NULL; - pa_sink_input *stream = NULL; - uint32_t idx; + stream_ducking *sd; void *state; pa_core_assert_ref(core); @@ -2611,17 +2609,17 @@ static pa_hook_result_t sink_input_ramp_finish_cb(pa_core *core, pa_sink_input * * Check the number of managed streams of the context id, if it is the last one * then broadcast a signal with context id.*/ PA_HASHMAP_FOREACH(sd, m->stream_duckings, state) { - PA_IDXSET_FOREACH(stream, sd->idx_ducking_streams, idx) { - if (stream == i && sd->ducking_stream_count > 0) { - pa_log_info("found matched stream(%p, index:%u) in sd(%p)", i, i->index, sd); - break; - } - } - if (stream != i) { + if (!pa_idxset_get_by_data(sd->idx_ducking_streams, i, NULL)) { pa_log_debug("not found matched stream(%p, index:%u) in sd(%p)", i, i->index, sd); continue; } + pa_log_info("found matched stream(%p, index:%u) in sd(%p, ducking_stream_count:%d, state:%u)", + i, i->index, sd, sd->ducking_stream_count, sd->state); + + if (sd->ducking_stream_count <= 0) + continue; + /* Remove trigger when unducked */ if (sd->state == STREAM_DUCKING_STATE_UNDUCKING) pa_idxset_remove_by_data(sd->idx_ducking_streams, (void *)i, NULL); @@ -2629,14 +2627,17 @@ static pa_hook_result_t sink_input_ramp_finish_cb(pa_core *core, pa_sink_input * /* Send signal when all streams are ducked. * Note that the condition of increasing count value below is located in * handle_activate_ducking() of DBus handler. */ - if (sd->ducking_stream_count > 0 && --sd->ducking_stream_count == 0) { - if (sd->state == STREAM_DUCKING_STATE_DUCKING) + if (--sd->ducking_stream_count == 0) { + if (sd->state == STREAM_DUCKING_STATE_DUCKING) { sd->state = STREAM_DUCKING_STATE_DUCKED; - else + } else if (sd->state == STREAM_DUCKING_STATE_UNDUCKING) { sd->state = STREAM_DUCKING_STATE_UNDUCKED; + } else { + pa_log_warn("sd->state(%d), already ducked or unducked, skip sending signal", sd->state); + continue; + } - pa_log_info("send signal for ramp finished - sd(%p, state:%d)", sd, sd->state); - + pa_log_info("send signal for ramp finished - sd(%p, state:%u)", sd, sd->state); send_ducking_state_changed_signal(pa_dbus_connection_get(m->dbus_conn), sd->trigger_index, is_stream_ducked(sd)); } }