+static void __unprepare_stream_info(void)
+{
+ int ret;
+
+ if (!g_stream_info_write_h) {
+ ERR("no stream to destroy");
+ return;
+ }
+
+ ret = sound_manager_destroy_stream_information(g_stream_info_write_h);
+ if (ret != SOUND_MANAGER_ERROR_NONE) {
+ ERR("Failed to destroy stream information");
+ return;
+ }
+
+ g_stream_info_write_h = NULL;
+}
+
+void stream_focus_cb(sound_stream_info_h stream_info, sound_stream_focus_mask_e focus_mask, sound_stream_focus_state_e focus_state,
+ sound_stream_focus_change_reason_e reason, int sound_behavior, const char *extra_info, void *user_data)
+{
+ return;
+}
+
+static gboolean __prepare_stream_info(void)
+{
+ int ret;
+ sound_device_list_h g_device_list = NULL;
+ sound_device_h device = NULL;
+ sound_device_type_e selected_type = SOUND_DEVICE_BUILTIN_SPEAKER;
+ sound_device_type_e type = SOUND_DEVICE_BUILTIN_SPEAKER;
+
+ if (TIZEN_MODEL_NAME_FHUB) {
+ char *processor = NULL;
+
+ system_info_get_platform_string("tizen.org/system/platform.processor", &processor);
+ if (processor) {
+ if (!strcasecmp(processor, "SDP1601")) {
+ DBG("set specific sound type");
+ selected_type = SOUND_DEVICE_BUILTIN_RECEIVER;
+ type = SOUND_DEVICE_BUILTIN_RECEIVER;
+ }
+ free(processor);
+ }
+ }
+
+ if (g_stream_info_write_h) {
+ ERR("there is already created one %p", g_stream_info_write_h);
+ __unprepare_stream_info();
+ }
+
+ ret = sound_manager_create_stream_information(SOUND_STREAM_TYPE_VOIP, stream_focus_cb, NULL, &g_stream_info_write_h);
+ if (ret != SOUND_MANAGER_ERROR_NONE) {
+ ERR("Failed to create stream information");
+ return FALSE;
+ }
+ INFO("created stream info %p", g_stream_info_write_h);
+
+ ret = sound_manager_get_device_list(SOUND_DEVICE_IO_DIRECTION_OUT_MASK, &g_device_list);
+ if (ret != SOUND_MANAGER_ERROR_NONE) {
+ ERR("fail to get current device list, ret(0x%x)\n", ret);
+ return FALSE;
+ }
+
+ // find voip device
+ while (!sound_manager_get_next_device(g_device_list, &device)) {
+ if ((ret = sound_manager_get_device_type(device, &type))) {
+ ERR("fail to get type of device, ret(0x%x)\n", ret);
+ break;
+ }
+
+ if (selected_type == type) {
+ DBG("try to set route for device\n");
+ ret = sound_manager_add_device_for_stream_routing(g_stream_info_write_h, device);
+ if (ret == SOUND_MANAGER_ERROR_NONE) {
+ ret = sound_manager_apply_stream_routing(g_stream_info_write_h);
+ if (ret != SOUND_MANAGER_ERROR_NONE)
+ ERR("failed to sound_manager_apply_stream_routing(), ret(0x%x)\n", ret);
+ } else {
+ ERR("failed to sound_manager_add_device_for_stream_routing(), ret(0x%x)\n", ret);
+ }
+ break;
+ }
+ }
+
+ ret = sound_manager_free_device_list(g_device_list);
+ if (ret != SOUND_MANAGER_ERROR_NONE)
+ ERR("fail to free device list, ret[0x%x]\n", ret);
+ else
+ g_device_list = NULL;
+
+ return TRUE;
+}
+