stream-manager-dbus: Send signal for ducking immediately when duration is 0 17/227817/7 accepted/tizen/unified/20200318.130518 submit/tizen/20200317.075627
authorJeongmo Yang <jm80.yang@samsung.com>
Mon, 16 Mar 2020 11:15:09 +0000 (20:15 +0900)
committerJeongmo Yang <jm80.yang@samsung.com>
Tue, 17 Mar 2020 07:48:18 +0000 (16:48 +0900)
- sink_input_ramp_finish_cb is not called when duration is 0

[Version] 13.0.6
[Profile] Common
[Issue Type] Bug fix

Change-Id: I292d620472a57b13ecaa6b69d81206e289552a6b
Signed-off-by: Jeongmo Yang <jm80.yang@samsung.com>
packaging/pulseaudio-modules-tizen.spec
src/stream-manager-dbus.c

index 1ae2b33..f6646fb 100644 (file)
@@ -1,6 +1,6 @@
 Name:             pulseaudio-modules-tizen
 Summary:          Pulseaudio modules for Tizen
-Version:          13.0.5
+Version:          13.0.6
 Release:          0
 Group:            Multimedia/Audio
 License:          LGPL-2.1+
index 1e30846..14ed732 100644 (file)
@@ -2162,8 +2162,9 @@ static void handle_activate_ducking(DBusConnection *conn, DBusMessage *msg, void
     double ratio = 0.0;
     DBusMessage *reply = NULL;
     pa_stream_manager *m = (pa_stream_manager*)userdata;
+    pa_cvolume vol;
+    pa_cvolume_ramp vol_ramp;
     stream_ducking *sd = NULL;
-    bool target_matched = false;
     hal_ducking_activation_info ducking_activation_info;
     ret_msg_t ret_msg = RET_MSG_OK;
 
@@ -2217,14 +2218,10 @@ static void handle_activate_ducking(DBusConnection *conn, DBusMessage *msg, void
         if (!pa_safe_streq(target_stream, pa_proplist_gets(i->proplist, PA_PROP_MEDIA_ROLE)))
             continue;
 
-        if (i->state == PA_SINK_INPUT_RUNNING) {
-            target_matched = true;
+        if (i->state == PA_SINK_INPUT_RUNNING)
             sd->ducking_stream_count++;
-        }
 
         if (enable) {
-            pa_cvolume_ramp vol_ramp;
-
             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]",
@@ -2233,8 +2230,7 @@ static void handle_activate_ducking(DBusConnection *conn, DBusMessage *msg, void
             pa_cvolume_ramp_set(&vol_ramp, i->volume.channels,
                 PA_VOLUME_RAMP_TYPE_LINEAR, (long)duration, sd->set_vol);
 
-            if (i->state != PA_SINK_INPUT_RUNNING) {
-                pa_cvolume vol;
+            if (i->state != PA_SINK_INPUT_RUNNING || duration == 0) {
                 pa_cvolume_set(&vol, i->volume.channels, sd->set_vol);
                 pa_sink_input_add_volume_factor(i, sd->vol_key, &vol);
                 pa_sink_input_add_volume_ramp_factor(i, sd->vol_key, &vol_ramp, false);
@@ -2273,15 +2269,19 @@ _ACTIVATE_DUCKING_DONE:
 
     pa_hal_interface_notify_ducking_activation_changed(m->hal, &ducking_activation_info);
 
-    if (target_matched == false) {
+    if (sd->ducking_stream_count <= 0 || duration == 0) {
         /* change ducking state and send signal here,
-           because ramp_finish_cb could not be called in this case */
+           because ramp_finish_cb could not be called in this case. */
         if (enable)
             sd->state = STREAM_DUCKING_STATE_DUCKED;
         else
             sd->state = STREAM_DUCKING_STATE_UNDUCKED;
 
-        pa_log_info("send signal for ramp finished(but, no stream matched) - state[%u]", sd->state);
+        pa_log_info("send signal for ramp finished - state[%u]", sd->state);
+
+        /* It should be reset here because it's increased,
+           but will not be decreased in case of 0 duration. */
+        sd->ducking_stream_count = 0;
 
         send_ducking_state_changed_signal(pa_dbus_connection_get(m->dbus_conn), sd->trigger_index, is_stream_ducked(sd));
     }