stream-manager: Improve sending ducking state changed signal 37/223937/1 accepted/tizen/5.5/unified/20200207.122814 submit/tizen_5.5/20200206.023454
authorSangchul Lee <sc11.lee@samsung.com>
Tue, 4 Feb 2020 03:39:32 +0000 (12:39 +0900)
committerSangchul Lee <sc11.lee@samsung.com>
Wed, 5 Feb 2020 06:31:46 +0000 (15:31 +0900)
If two or more ducking requests have been activated to the same
target stream type during ducking operation, ducking state changed
signal should be emitted for each ducking request handle respectively.
Previously, it did not work well. It is now fixed.

Note that these ducking state changed signals will be emitted at the
same time when the sink-input's ramp finish hook is called in the
thread context as soon as the final ducking operation has been done.

[Version] 11.1.94
[Issue Type] Bug fix

Change-Id: I3de608a7053c6c61e74ff67af271d2972f5149a1
Signed-off-by: Sangchul Lee <sc11.lee@samsung.com>
packaging/pulseaudio-modules-tizen.spec
src/stream-manager.c

index ce666c8f5a707bc679fc9ab72e139c9b591e74bb..b5bf22f3446fe37617a9ab7cc789ca175076b97c 100644 (file)
@@ -1,6 +1,6 @@
 Name:             pulseaudio-modules-tizen
 Summary:          Pulseaudio modules for Tizen
-Version:          11.1.93
+Version:          11.1.94
 Release:          0
 Group:            Multimedia/Audio
 License:          LGPL-2.1+
index 59e25dd137957a93dd83780642091d7631aa617a..fc5c8e99e20814d690fba379d9fbffaab510fb99 100644 (file)
@@ -2580,36 +2580,32 @@ static pa_hook_result_t sink_input_ramp_finish_cb(pa_core *core, pa_sink_input *
     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("matched (%p,%p)", sd, i);
+                pa_log_info("found matched stream(%p, index:%u) in sd(%p)", i, i->index, sd);
                 break;
             }
         }
+        if (stream != i) {
+            pa_log_debug("not found matched stream(%p, index:%u) in sd(%p)", i, i->index, sd);
+            continue;
+        }
 
-        if (stream == i)
-            break;
-    }
-
-    if (stream != i) {
-        pa_log_error("not found matched stream for %p", i);
-        return PA_HOOK_OK;
-    }
-
-    /* Remove trigger when unducked */
-    if (sd->state == STREAM_DUCKING_STATE_UNDUCKING)
-        pa_idxset_remove_by_data(sd->idx_ducking_streams, (void *)i, NULL);
+        /* Remove trigger when unducked */
+        if (sd->state == STREAM_DUCKING_STATE_UNDUCKING)
+            pa_idxset_remove_by_data(sd->idx_ducking_streams, (void *)i, NULL);
 
-    /* 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)
-            sd->state = STREAM_DUCKING_STATE_DUCKED;
-        else
-            sd->state = STREAM_DUCKING_STATE_UNDUCKED;
+        /* 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)
+                sd->state = STREAM_DUCKING_STATE_DUCKED;
+            else
+                sd->state = STREAM_DUCKING_STATE_UNDUCKED;
 
-        pa_log_info("send signal for ramp finished - state(%p,%d)", sd, sd->state);
+            pa_log_info("send signal for ramp finished - sd(%p, state:%d)", sd, sd->state);
 
-        send_ducking_state_changed_signal(pa_dbus_connection_get(m->dbus_conn), sd->trigger_index, is_stream_ducked(sd));
+            send_ducking_state_changed_signal(pa_dbus_connection_get(m->dbus_conn), sd->trigger_index, is_stream_ducked(sd));
+        }
     }
 
     return PA_HOOK_OK;