Set default playback route to headphone and change by route option
[platform/adaptation/ap_broadcom/audio-hal-bcm2837.git] / tizen-audio-routing.c
index 406c5d6..fbf0f8a 100644 (file)
@@ -29,8 +29,7 @@
 #include "tizen-audio-internal.h"
 #include "tizen-audio-impl.h"
 
-#include <system_info.h>
-#define FEATURE_DISPLAY "http://tizen.org/feature/display"
+#include <vconf.h>
 
 /* #define DEBUG_TIMING */
 
@@ -247,19 +246,16 @@ static audio_return_e __update_route_reset(audio_hal_s *ah, uint32_t direction)
 
 static void __audio_routing_playback_rpi3(audio_hal_s *ah)
 {
-    bool display_avail = false;
-    int ret = SYSTEM_INFO_ERROR_NONE;
-
-    ret = system_info_get_platform_bool(FEATURE_DISPLAY, &display_avail);
-    AUDIO_LOG_INFO("system_info_platform [%s]=[%d], ret[%d]", FEATURE_DISPLAY, display_avail, ret);
-    if (ret != SYSTEM_INFO_ERROR_NONE)
-        AUDIO_LOG_ERROR("Failed to get feature...");
-
-    if (!display_avail) {
-        /* in case of headless (display is not available), force to use earjack(1) only.
-           supported value : (0)auto (1)earjack (2)hdmi */
-        _mixer_control_set_value(ah, "PCM Playback Route", 1);
+    int type;
+    int ret;
+
+    ret = vconf_get_int(VCONFKEY_SOUND_RPI_PLAYBACK_ROUTE, &type);
+    if (ret != 0) {
+        AUDIO_LOG_ERROR("Failed to get vconf [%s], err [%d]", VCONFKEY_SOUND_RPI_PLAYBACK_ROUTE, ret);
+        return;
     }
+
+    _mixer_control_set_value(ah, "PCM Playback Route", type);
 }
 
 audio_return_e _audio_routing_init(audio_hal_s *ah)
@@ -321,11 +317,23 @@ audio_return_e audio_update_route_option(void *audio_handle, audio_route_option_
 {
     audio_return_e audio_ret = AUDIO_RET_OK;
     audio_hal_s *ah = (audio_hal_s *)audio_handle;
+    int ret;
 
     AUDIO_RETURN_VAL_IF_FAIL(ah, AUDIO_ERR_PARAMETER);
     AUDIO_RETURN_VAL_IF_FAIL(option, AUDIO_ERR_PARAMETER);
 
     AUDIO_LOG_INFO("role:%s, name:%s, value:%d", option->role, option->name, option->value);
 
+    if (!strcmp("rpi playback route", option->name)) {
+        audio_ret = _mixer_control_set_value(ah, "PCM Playback Route", option->value);
+        if (audio_ret == AUDIO_RET_OK) {
+            ret = vconf_set_int(VCONFKEY_SOUND_RPI_PLAYBACK_ROUTE, option->value);
+            if (ret != 0) {
+                AUDIO_LOG_ERROR("Failed to set vconf [%s], err [%d]", VCONFKEY_SOUND_RPI_PLAYBACK_ROUTE, ret);
+                return AUDIO_ERR_INTERNAL;
+            }
+        }
+    }
+
     return audio_ret;
 }