murphy support: setting the media.role property of pulseaudio streams
authorJaska Uimonen <jaska.uimonen@helsinki.fi>
Wed, 7 Nov 2012 12:57:55 +0000 (14:57 +0200)
committerIsmo Puustinen <ismo.puustinen@intel.com>
Mon, 11 Mar 2013 11:47:36 +0000 (13:47 +0200)
avsys-audio-pasimple.c

index 7bbe983..bc71eb4 100644 (file)
@@ -27,7 +27,7 @@
 #include "avsys-error.h"
 #include "avsys-debug.h"
 
-#ifdef MURPHY_SUPPORT
+#ifndef MURPHY_SUPPORT
 #define PA_PROP_MEDIA_POLICY   "media.policy"
 #endif
 
@@ -97,6 +97,10 @@ int avsys_audio_pasimple_open_device(const int mode, const unsigned int format,
        if(count)
                p_count = atoi(count);
 
+#ifdef MURPHY_SUPPORT
+        const char *media_role;
+#endif
+
        avsys_info(AVAUDIO, ">>>[%s] mode=%d, format=%d, channel=%d, samplerate=%d\n", __func__, mode, format, channel, samplerate);
        avsys_assert(handle != NULL);
 
@@ -135,6 +139,44 @@ int avsys_audio_pasimple_open_device(const int mode, const unsigned int format,
 
        /* Set policy property */
        avsys_info(AVAUDIO, ">>>[%s] policy=[%d], vol_type=[%d]\n", __func__, policy, vol_conf_type);
+
+#ifdef MURPHY_SUPPORT
+    switch (vol_conf_type) {
+
+       case AVSYS_AUDIO_VOLUME_TYPE_SYSTEM:
+            media_role = "system";
+            break;
+
+       case AVSYS_AUDIO_VOLUME_TYPE_NOTIFICATION:
+            media_role = "event";
+            break;
+
+       case AVSYS_AUDIO_VOLUME_TYPE_ALARM:
+            media_role = "alarm";
+            break;
+
+       case AVSYS_AUDIO_VOLUME_TYPE_RINGTONE:
+            media_role = "ringtone";
+            break;
+
+       case AVSYS_AUDIO_VOLUME_TYPE_MEDIA:
+            media_role = "music";
+            break;
+
+       case AVSYS_AUDIO_VOLUME_TYPE_CALL:
+            media_role = "phone";
+            break;
+
+       case AVSYS_AUDIO_VOLUME_TYPE_FIXED:
+       case AVSYS_AUDIO_VOLUME_TYPE_EXT_SYSTEM_JAVA:
+    default:
+            media_role = "music";
+            break;
+        }
+
+        avsys_info(AVAUDIO, ": set media role to '%s'\n", media_role);
+        pa_proplist_sets(proplist, PA_PROP_MEDIA_ROLE, media_role);
+#else
        if (policy == AVSYS_AUDIO_HANDLE_ROUTE_HANDSET_ONLY) {
                avsys_info(AVAUDIO, ": set media plicy to PHONE\n");
                pa_proplist_sets(proplist, PA_PROP_MEDIA_POLICY, MEDIA_POLICY_PHONE);
@@ -161,6 +203,7 @@ int avsys_audio_pasimple_open_device(const int mode, const unsigned int format,
                        break;
                }
        }
+#endif
 
        handle->handle_route = policy;