stream-manager: Add condition to set active-dev prop. only if it is auto/audio-last... 19/96719/2 accepted/tizen/common/20161122.192945 accepted/tizen/ivi/20161122.235945 accepted/tizen/mobile/20161122.235731 accepted/tizen/tv/20161122.235815 accepted/tizen/wearable/20161122.235852 submit/tizen/20161122.044017
authorSangchul Lee <sc11.lee@samsung.com>
Thu, 10 Nov 2016 03:55:37 +0000 (12:55 +0900)
committerSangchul Lee <sc11.lee@samsung.com>
Thu, 10 Nov 2016 06:57:36 +0000 (15:57 +0900)
The condition is added in update_the_highest_priority_stream()
Use a static function instead of macro to set new data stream to null sink(source)

[Version] 5.0.93
[Profile] Common
[Issue Type] Feature Enhancement

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

index 58cccd2..0e8bd6a 100644 (file)
@@ -1,6 +1,6 @@
 Name:             pulseaudio-modules-tizen
 Summary:          Pulseaudio modules for Tizen
-Version:          5.0.92
+Version:          5.0.93
 Release:          0
 Group:            Multimedia/Audio
 License:          LGPL-2.1+
index 738032f..d10b859 100644 (file)
@@ -462,24 +462,6 @@ typedef struct _stream_route_option {
         x_device_role = DEVICE_ROLE_NORMAL; \
 } \
 
-#define SET_NEW_DATA_STREAM_TO_NULL_SINK_SOURCE(x_m, x_stream, x_stream_type) { \
-    pa_sink *null_sink; \
-    pa_source *null_source; \
-    if (x_stream_type == STREAM_SINK_INPUT && \
-        (!((pa_sink_input_new_data*)x_stream)->sink)) { \
-        if ((null_sink = (pa_sink*)pa_namereg_get(x_m->core, SINK_NAME_NULL, PA_NAMEREG_SINK))) \
-            ((pa_sink_input_new_data*)x_stream)->sink = null_sink; \
-        else \
-            pa_log_warn("could not get null_sink"); \
-    } else if (x_stream_type == STREAM_SOURCE_OUTPUT && \
-               (!((pa_source_output_new_data*)x_stream)->source)) { \
-        if ((null_source = (pa_source*)pa_namereg_get(x_m->core, SOURCE_NAME_NULL, PA_NAMEREG_SOURCE))) \
-            ((pa_source_output_new_data*)x_stream)->source = null_source; \
-        else \
-            pa_log_warn("could not get null_source"); \
-    } \
-} \
-
 static void do_notify(pa_stream_manager *m, notify_command_type_t command, stream_type_t type, bool is_new_data, void *user_data);
 static process_stream_result_t process_stream(pa_stream_manager *m, void *stream, stream_type_t type, process_command_type_t command, bool is_new_data);
 
@@ -1950,11 +1932,13 @@ static bool update_the_highest_priority_stream(pa_stream_manager *m, process_com
                     } else {
                         /* no need to trigger,
                          * update active device info if possible */
-                        if ((active_dev = pa_proplist_gets(GET_STREAM_PROPLIST(cur_max_stream, type), PA_PROP_MEDIA_ROUTE_AUTO_ACTIVE_DEV))) {
-                            if (is_new_data)
-                                pa_proplist_sets(GET_STREAM_NEW_PROPLIST(mine, type), PA_PROP_MEDIA_ROUTE_AUTO_ACTIVE_DEV, active_dev);
-                            else
-                                pa_proplist_sets(GET_STREAM_PROPLIST(mine, type), PA_PROP_MEDIA_ROUTE_AUTO_ACTIVE_DEV, active_dev);
+                        if (IS_ROUTE_TYPE_FOR_AUTO(route_type_str, route_type) || IS_ROUTE_TYPE_FOR_AUTO_LAST_CONN(route_type_str, route_type)) {
+                            if ((active_dev = pa_proplist_gets(GET_STREAM_PROPLIST(cur_max_stream, type), PA_PROP_MEDIA_ROUTE_AUTO_ACTIVE_DEV))) {
+                                if (is_new_data)
+                                    pa_proplist_sets(GET_STREAM_NEW_PROPLIST(mine, type), PA_PROP_MEDIA_ROUTE_AUTO_ACTIVE_DEV, active_dev);
+                                else
+                                    pa_proplist_sets(GET_STREAM_PROPLIST(mine, type), PA_PROP_MEDIA_ROUTE_AUTO_ACTIVE_DEV, active_dev);
+                            }
                         }
                         return true;
                     }
@@ -2408,6 +2392,26 @@ static int update_forwarding_device(pa_stream_manager *m, bool load) {
     return 0;
 }
 
+static void set_new_data_stream_to_null_sink_source(pa_stream_manager *m, void *stream, stream_type_t type) {
+    pa_sink *null_sink;
+    pa_source *null_source;
+
+    pa_assert(m);
+    pa_assert(stream);
+
+    if (type == STREAM_SINK_INPUT && !((pa_sink_input_new_data*)stream)->sink) {
+        if ((null_sink = (pa_sink*)pa_namereg_get(m->core, SINK_NAME_NULL, PA_NAMEREG_SINK)))
+            ((pa_sink_input_new_data*)stream)->sink = null_sink;
+        else
+            pa_log_warn("could not get null_sink");
+    } else if (type == STREAM_SOURCE_OUTPUT && !((pa_source_output_new_data*)stream)->source) {
+        if ((null_source = (pa_source*)pa_namereg_get(m->core, SOURCE_NAME_NULL, PA_NAMEREG_SOURCE)))
+            ((pa_source_output_new_data*)stream)->source = null_source;
+        else
+            pa_log_warn("could not get null_source");
+    }
+}
+
 static process_stream_result_t process_stream(pa_stream_manager *m, void *stream, stream_type_t type, process_command_type_t command, bool is_new_data) {
     process_stream_result_t result = PROCESS_STREAM_RESULT_OK;
     const char *role = NULL;
@@ -2435,7 +2439,7 @@ static process_stream_result_t process_stream(pa_stream_manager *m, void *stream
         result = PROCESS_STREAM_RESULT_SKIP;
         /* set it to null sink/source */
         if (is_new_data)
-            SET_NEW_DATA_STREAM_TO_NULL_SINK_SOURCE(m, stream, type);
+            set_new_data_stream_to_null_sink_source(m, stream, type);
         goto finish;
     }
 
@@ -2515,7 +2519,7 @@ static process_stream_result_t process_stream(pa_stream_manager *m, void *stream
             pa_log_debug("skip notifying for selecting sink/source, rather set it to null sink/source");
             /* set it to null sink/source */
             if (is_new_data)
-                SET_NEW_DATA_STREAM_TO_NULL_SINK_SOURCE(m, stream, type);
+                set_new_data_stream_to_null_sink_source(m, stream, type);
 
         } else {
             /* notify to select sink or source */
@@ -3408,7 +3412,7 @@ static pa_hook_result_t device_connection_changed_hook_cb(pa_core *c, pa_tz_devi
                             ((route_type == STREAM_ROUTE_TYPE_AUTO) || (route_type == STREAM_ROUTE_TYPE_AUTO_LAST_CONNECTED))) {
                             /* remove activated device info. if it has the AUTO route type */
                             active_dev = pa_proplist_gets(GET_STREAM_PROPLIST(s, STREAM_SOURCE_OUTPUT), PA_PROP_MEDIA_ROUTE_AUTO_ACTIVE_DEV);
-                            if (active_dev && pa_streq(active_dev, device_type))
+                            if (pa_safe_streq(active_dev, device_type))
                                 pa_proplist_sets(GET_STREAM_PROPLIST(s, STREAM_SOURCE_OUTPUT), PA_PROP_MEDIA_ROUTE_AUTO_ACTIVE_DEV, ACTIVE_DEV_REMOVED);
                         }
                     }
@@ -3432,7 +3436,7 @@ static pa_hook_result_t device_connection_changed_hook_cb(pa_core *c, pa_tz_devi
                             ((route_type == STREAM_ROUTE_TYPE_AUTO) || (route_type == STREAM_ROUTE_TYPE_AUTO_LAST_CONNECTED))) {
                             /* remove activated device info. if it has the AUTO route type */
                             active_dev = pa_proplist_gets(GET_STREAM_PROPLIST(s, STREAM_SINK_INPUT), PA_PROP_MEDIA_ROUTE_AUTO_ACTIVE_DEV);
-                            if (active_dev && pa_streq(active_dev, device_type))
+                            if (pa_safe_streq(active_dev, device_type))
                                 pa_proplist_sets(GET_STREAM_PROPLIST(s, STREAM_SINK_INPUT), PA_PROP_MEDIA_ROUTE_AUTO_ACTIVE_DEV, ACTIVE_DEV_REMOVED);
                         }
                     }
index b90d65b..4779fc7 100644 (file)
@@ -30,6 +30,9 @@
 #define IS_ROUTE_TYPE_FOR_AUTO(route_type_str, route_type) \
       (route_type_str && !pa_atoi(route_type_str, (int32_t*)&route_type) && (route_type == STREAM_ROUTE_TYPE_AUTO))
 
+#define IS_ROUTE_TYPE_FOR_AUTO_LAST_CONN(route_type_str, route_type) \
+      (route_type_str && !pa_atoi(route_type_str, (int32_t*)&route_type) && (route_type == STREAM_ROUTE_TYPE_AUTO_LAST_CONNECTED))
+
 #define GET_STREAM_NEW_PROPLIST(stream, type) \
       (type == STREAM_SINK_INPUT ? ((pa_sink_input_new_data*)stream)->proplist : ((pa_source_output_new_data*)stream)->proplist)