stream-manager: Set focus state to acquired forcedly in case of solo series stream 58/108358/2
authorSangchul Lee <sc11.lee@samsung.com>
Wed, 4 Jan 2017 05:57:03 +0000 (14:57 +0900)
committerSangchul Lee <sc11.lee@samsung.com>
Wed, 4 Jan 2017 06:42:07 +0000 (15:42 +0900)
Stream roles like solo are important to secure their own routing path even though
they do not acquire a focus. This patch updates focus state forcedly in this case.

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

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

index a158f8c200dce007c9a4a9470b70c51ea463e2d8..5d4c8899a458b812dcf5a088f31cae86758c85f2 100644 (file)
@@ -1,6 +1,6 @@
 Name:             pulseaudio-modules-tizen
 Summary:          Pulseaudio modules for Tizen
-Version:          5.0.118
+Version:          5.0.119
 Release:          0
 Group:            Multimedia/Audio
 License:          LGPL-2.1+
index 6ce27023bda5d181d6348aaf08218fd3b37dad3c..36dcfe3e9fc12ba710ba5c7e5c14b78e255ace58 100644 (file)
@@ -361,9 +361,8 @@ static pa_dbus_interface_info stream_manager_interface_info = {
 #define NAME_FOR_SKIP_MAX 1
 const char* stream_manager_media_names_for_skip[NAME_FOR_SKIP_MAX] = {"pulsesink probe"};
 
-#define STREAM_FOCUS_NONE     "0"
-#define STREAM_FOCUS_PLAYBACK "1"
-#define STREAM_FOCUS_CAPTURE  "2"
+#define STREAM_FOCUS_STATE_RELEASED    "0"
+#define STREAM_FOCUS_STATE_ACQUIRED    "1"
 
 typedef enum _process_stream_result {
     PROCESS_STREAM_RESULT_OK,
@@ -1525,7 +1524,7 @@ static void handle_update_focus_status(DBusConnection *conn, DBusMessage *msg, v
                 count = pa_idxset_size(sp->idx_sink_inputs);
                 PA_IDXSET_FOREACH(stream, sp->idx_sink_inputs, idx) {
                     pa_proplist_sets(GET_STREAM_PROPLIST(stream, STREAM_SINK_INPUT), PA_PROP_MEDIA_FOCUS_STATUS,
-                                     GET_FOCUS_STATUS(sp->focus_status, STREAM_SINK_INPUT) ? STREAM_FOCUS_PLAYBACK : STREAM_FOCUS_NONE);
+                                     GET_FOCUS_STATUS(sp->focus_status, STREAM_SINK_INPUT) ? STREAM_FOCUS_STATE_ACQUIRED : STREAM_FOCUS_STATE_RELEASED);
                     if (--count == 0)
                         process_stream(m, stream, STREAM_SINK_INPUT, PROCESS_COMMAND_CHANGE_ROUTE_BY_STREAM_FOCUS_CHANGED, false);
                 }
@@ -1534,7 +1533,7 @@ static void handle_update_focus_status(DBusConnection *conn, DBusMessage *msg, v
                 count = pa_idxset_size(sp->idx_source_outputs);
                 PA_IDXSET_FOREACH(stream, sp->idx_source_outputs, idx) {
                     pa_proplist_sets(GET_STREAM_PROPLIST(stream, STREAM_SOURCE_OUTPUT), PA_PROP_MEDIA_FOCUS_STATUS,
-                                     GET_FOCUS_STATUS(sp->focus_status, STREAM_SOURCE_OUTPUT) ? STREAM_FOCUS_CAPTURE : STREAM_FOCUS_NONE);
+                                     GET_FOCUS_STATUS(sp->focus_status, STREAM_SOURCE_OUTPUT) ? STREAM_FOCUS_STATE_ACQUIRED : STREAM_FOCUS_STATE_RELEASED);
                     if (--count == 0)
                         process_stream(m, stream, STREAM_SOURCE_OUTPUT, PROCESS_COMMAND_CHANGE_ROUTE_BY_STREAM_FOCUS_CHANGED, false);
                 }
@@ -2179,21 +2178,31 @@ static bool update_volume_type_of_stream(pa_stream_manager *m, void *stream, str
     return ret;
 }
 
-/* FIXME : this code is workaround code and needed to be revised soon */
-static void _enable_focus_status_if_radio(void *stream, stream_type_t type, bool is_new_data)
+static void _set_focus_status_forcedly_if_needed(pa_stream_manager *m, void *stream, stream_type_t type, bool is_new_data)
 {
-    const char *prop_media_role = NULL;
+    const char *role = NULL;
     pa_proplist* p = NULL;
 
+    pa_assert(m);
+    pa_assert(stream);
+
     p = (is_new_data ? GET_STREAM_NEW_PROPLIST(stream, type) : GET_STREAM_PROPLIST(stream, type));
     if (!p)
         return;
 
-    prop_media_role = pa_proplist_gets(p, PA_PROP_MEDIA_ROLE);
-    if (prop_media_role) {
-       if (pa_safe_streq(prop_media_role, STREAM_ROLE_RADIO)) {
-            pa_log_info("This stream is radio, update focus status to 1");
-            pa_proplist_setf(p, PA_PROP_MEDIA_FOCUS_STATUS, "%u", 1);
+    if ((role = pa_proplist_gets(p, PA_PROP_MEDIA_ROLE))) {
+        if (!pa_hashmap_get(m->stream_infos, role)) {
+            pa_log_warn("undefined role[%s], skip it", role);
+            return;
+        }
+        if (pa_safe_streq(role, STREAM_ROLE_SOLO)) {
+            pa_log_info("This stream is [%s], update focus status to STREAM_FOCUS_STATE_ACQUIRED", role);
+            pa_proplist_setf(p, PA_PROP_MEDIA_FOCUS_STATUS, "%s", STREAM_FOCUS_STATE_ACQUIRED);
+        }
+        /* FIXME : this code is workaround code and needed to be revised soon */
+        else if (pa_safe_streq(role, STREAM_ROLE_RADIO)) {
+            pa_log_info("This stream is [%s], update focus status to STREAM_FOCUS_STATE_ACQUIRED", role);
+            pa_proplist_setf(p, PA_PROP_MEDIA_FOCUS_STATUS, "%s", STREAM_FOCUS_STATE_ACQUIRED);
         }
     }
 }
@@ -2218,9 +2227,6 @@ static bool update_focus_status_of_stream(pa_stream_manager *m, void *stream, st
             else
                 pa_proplist_setf(GET_STREAM_PROPLIST(stream, type), PA_PROP_MEDIA_FOCUS_STATUS, "%u", sp->focus_status);
 
-            /* FIXME : If stream is radio, then fix focus_status to 1 */
-            _enable_focus_status_if_radio(stream, type, is_new_data);
-
             pa_log_debug("p_idx(%s), idx(%u), focus_status(0x%x, 0x1:playback 0x2:capture 0x3:both)", p_idx, parent_idx, sp->focus_status);
         } else {
             pa_log_error("could not find matching client for this parent_id(%u)", parent_idx);
@@ -2228,6 +2234,9 @@ static bool update_focus_status_of_stream(pa_stream_manager *m, void *stream, st
         }
     }
 
+    /* set focus status regardless of parent id existence */
+    _set_focus_status_forcedly_if_needed(m, stream, type, is_new_data);
+
     return true;
 }
 
index e2865c0c0d85b48416e3454fc7304c2859dcb475..5eb5fab0784ea0406f09daf84c083fab2068e5d2 100644 (file)
@@ -47,6 +47,7 @@
 #define STREAM_ROLE_LOOPBACK            "loopback"
 #define STREAM_ROLE_LOOPBACK_MIRRORING  "loopback-mirroring"
 #define STREAM_ROLE_RADIO               "radio"
+#define STREAM_ROLE_SOLO                "solo"
 
 #define SINK_NAME_COMBINED              "sink_combined"
 #define SINK_NAME_NULL                  "sink_null"