stream-manager: Do not apply tizen group volume to a stream belongs to a network... 37/208237/2 accepted/tizen/unified/20190621.121845 submit/tizen/20190620.095920
authorSangchul Lee <sc11.lee@samsung.com>
Thu, 20 Jun 2019 07:27:55 +0000 (16:27 +0900)
committerSangchul Lee <sc11.lee@samsung.com>
Thu, 20 Jun 2019 09:49:01 +0000 (18:49 +0900)
Let it just go without manipulating volume value that is according to
tizen group volume when a stream goes to a network device. Note that
only individual volume can be applied to these streams.

[Version] 11.1.54
[Issue type] Improvement

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

index cb28959..17174f8 100644 (file)
@@ -1,6 +1,6 @@
 Name:             pulseaudio-modules-tizen
 Summary:          Pulseaudio modules for Tizen
-Version:          11.1.53
+Version:          11.1.54
 Release:          0
 Group:            Multimedia/Audio
 License:          LGPL-2.1+
index c9254ad..7c2aa36 100644 (file)
@@ -251,6 +251,7 @@ struct _stream_manager {
 };
 
 bool stream_is_call_family(pa_object *stream);
+bool is_active_device_of_stream(const void *stream, stream_type_t stream_type, const char *device_type);
 int32_t get_route_type(void *stream, stream_type_t stream_type, bool is_new_data, stream_route_type_t *stream_route_type);
 int32_t get_stream_info(pa_stream_manager *m, const char *stream_role, stream_info_per_type *info);
 int32_t get_available_streams(pa_stream_manager *m, stream_list *list);
index 10cda8e..06e0536 100644 (file)
@@ -320,7 +320,7 @@ void apply_individual_ratio(pa_stream_manager *m, pa_object *stream, double volu
         }
         group_ratio = v->is_hal_volume_type ? 1.0 : (double)v->values[stream_direction].current_level / (pa_idxset_size(v->values[stream_direction].idx_volume_values) - 1);
         result_ratio = master_ratio * group_ratio * individual_ratio;
-        pa_log_debug("role(%s), volume_type(%s) : master_ratio(%f), group_ratio(%f), individual_ratio(%f) => result_ratio(%f)",
+        pa_log_debug("role(%s), volume_type(%s) : master_ratio(%f), group_ratio(%f), individual_ratio(%f) => result_ratio(%f) to HAL",
                     role, volume_type, master_ratio, group_ratio, individual_ratio, result_ratio);
 
         io_direction = is_sink_input ? DIRECTION_OUT : DIRECTION_IN;
@@ -664,6 +664,11 @@ int32_t set_volume_ratio_by_idx(pa_stream_manager *m, stream_type_t stream_type,
         ((pa_sink_input*)s)->individual_volume_ratio = ratio;
     else
         ((pa_source_output*)s)->individual_volume_ratio = ratio;
+
+    /* In case of network device, do not apply tizen group volume */
+    if (is_active_device_of_stream(s, stream_type, DEVICE_TYPE_NETWORK))
+        volume_linear = 1.0;
+
     apply_individual_ratio(m, s, volume_linear, &cv);
 
     if (stream_type == STREAM_SINK_INPUT)
index 6574b31..c0bc99d 100644 (file)
@@ -533,6 +533,21 @@ int change_active_route_for_call(pa_stream_manager *m, pa_object *stream, bool s
     return 0;
 }
 
+bool is_active_device_of_stream(const void *stream, stream_type_t stream_type, const char *device_type) {
+    const char *active_dev;
+
+    pa_assert(stream);
+    pa_assert(device_type);
+
+    active_dev = pa_proplist_gets(GET_STREAM_PROPLIST(stream, stream_type), PA_PROP_MEDIA_ROUTE_AUTO_ACTIVE_DEV);
+    if (pa_safe_streq(active_dev, device_type)) {
+        pa_log_info("stream(%p)'s active_dev(%s) is same as device_type(%s)", stream, active_dev, device_type);
+        return true;
+    }
+
+    return false;
+}
+
 static void set_media_active_device(pa_stream_manager *m) {
     pa_tz_device *playback_device, *capture_device;
     stream_info *media_info;
@@ -2001,10 +2016,19 @@ process_stream_result_t process_stream(pa_stream_manager *m, void *stream, strea
         }
 
     } else if (command == PROCESS_COMMAND_UPDATE_VOLUME) {
-        if (is_new_data)
+        if (is_new_data) {
             si_volume_type_str = pa_proplist_gets(GET_STREAM_NEW_PROPLIST(stream, type), PA_PROP_MEDIA_TIZEN_VOLUME_TYPE);
-        else
+        } else {
             si_volume_type_str = pa_proplist_gets(GET_STREAM_PROPLIST(stream, type), PA_PROP_MEDIA_TIZEN_VOLUME_TYPE);
+            if (si_volume_type_str && is_active_device_of_stream(stream, STREAM_SINK_INPUT, DEVICE_TYPE_NETWORK)) {
+                /* In case of network device, reset the volume of this sink-input. */
+                pa_cvolume cv;
+                pa_cvolume_reset(&cv, ((pa_sink_input*)stream)->sample_spec.channels) ;
+                pa_sink_input_set_volume((pa_sink_input*)stream, &cv, true, true);
+                pa_log_debug("This stream belongs to a network device, reset volume.");
+                goto finish;
+            }
+        }
 
         if (!si_volume_type_str)
             goto finish;
@@ -2184,6 +2208,7 @@ static pa_hook_result_t sink_input_move_start_cb(pa_core *core, pa_sink_input *i
     pa_log_debug("sink-input(%p, index:%u)", i, i->index);
 
     set_volume_mute_by_idx(m, i->index, STREAM_SINK_INPUT, true);
+    process_stream(m, i, STREAM_SINK_INPUT, PROCESS_COMMAND_UPDATE_VOLUME, false);
 
     return PA_HOOK_OK;
 }
@@ -2432,21 +2457,6 @@ static void is_available_device_for_auto_route(pa_stream_manager *m, stream_rout
     pa_log_debug("is new_device[%s] available for role[%s]/stream_type[%d]:%d", new_device_type, role, stream_type, *available);
 }
 
-static bool is_active_device_of_stream(const void *stream, stream_type_t stream_type, const char *device_type) {
-    const char *active_dev;
-
-    pa_assert(stream);
-    pa_assert(device_type);
-
-    active_dev = pa_proplist_gets(GET_STREAM_PROPLIST(stream, stream_type), PA_PROP_MEDIA_ROUTE_AUTO_ACTIVE_DEV);
-    if (pa_safe_streq(active_dev, device_type)) {
-        pa_log_info("stream(%p)'s active_dev(%s) is same as device_type(%s)", stream, active_dev, device_type);
-        return true;
-    }
-
-    return false;
-}
-
 /* Re-trigger for routing update for streams using auto route type */
 static void process_stream_as_device_change_for_auto_route(pa_stream_manager *m, void *stream, stream_type_t stream_type,
                                                            bool is_connected, pa_tz_device *device) {
@@ -2643,6 +2653,7 @@ static void update_sink_or_source_as_device_change(pa_stream_manager *m, stream_
                             if (check_name_is_vstream(s, STREAM_SINK_INPUT, false)) {
                                 pa_log_debug("  -- *** keep null sink for a virtual stream");
                             } else {
+                                pa_proplist_sets(GET_STREAM_PROPLIST(s, STREAM_SINK_INPUT), PA_PROP_MEDIA_ROUTE_AUTO_ACTIVE_DEV, device_type);
                                 pa_sink_input_move_to(s, sink, false);
                                 pa_log_debug("  -- *** sink-input(%p,%u) moves to sink(%p,%s), new device(%s)",
                                             s, ((pa_sink_input*)s)->index, sink, sink->name, device_type);
@@ -2657,6 +2668,7 @@ static void update_sink_or_source_as_device_change(pa_stream_manager *m, stream_
                             if (check_name_is_vstream(s, STREAM_SOURCE_OUTPUT, false)) {
                                 pa_log_debug("  -- *** keep null source for a virtual stream");
                             } else {
+                                pa_proplist_sets(GET_STREAM_PROPLIST(s, STREAM_SOURCE_OUTPUT), PA_PROP_MEDIA_ROUTE_AUTO_ACTIVE_DEV, device_type);
                                 pa_source_output_move_to(s, source, false);
                                 pa_log_debug("  -- *** source-output(%p,%u) moves to source(%p,%s), new device(%s)",
                                             s, ((pa_source_output*)s)->index, source, source->name, device_type);