From: Sangchul Lee Date: Fri, 25 Mar 2016 03:15:30 +0000 (+0900) Subject: Add condition not to check argument of focus callback in case of sound_manager_create... X-Git-Tag: submit/tizen/20160325.051148^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a198cfd44380f0da8d64d7493c3ffeea1954f3bc;p=platform%2Fcore%2Fapi%2Fsound-manager.git Add condition not to check argument of focus callback in case of sound_manager_create_stream_information_internal() API Some internal stream types do not support for focus. In these cases, the focus callback signifies nothing. [Version] Release 0.3.49 [Profile] Common [Issue Type] Code enhancement Change-Id: I24b74cdbfd0f31cc25a50a347372f6e86dd8bdd1 Signed-off-by: Sangchul Lee --- diff --git a/include/sound_manager_internal.h b/include/sound_manager_internal.h index dd02108..50ca8c4 100644 --- a/include/sound_manager_internal.h +++ b/include/sound_manager_internal.h @@ -122,7 +122,7 @@ int sound_manager_get_master_volume(int *level); * @details To apply the stream policy according to this stream information, this handle should be passed to other APIs\n * related to playback or recording. (e.g., player, wav-player, audio-io, etc.) * @param[in] stream_type The type of stream for internal usage - * @param[in] callback The focus state change callback function (mandatory) + * @param[in] callback The focus state change callback function * @param[in] user_data The user data to be passed to the callback function * @param[out] stream_info The handle of stream information * diff --git a/packaging/capi-media-sound-manager.spec b/packaging/capi-media-sound-manager.spec index 257d3ac..5df7c95 100755 --- a/packaging/capi-media-sound-manager.spec +++ b/packaging/capi-media-sound-manager.spec @@ -1,6 +1,6 @@ Name: capi-media-sound-manager Summary: Sound Manager library -Version: 0.3.48 +Version: 0.3.49 Release: 0 Group: Multimedia/API License: Apache-2.0 diff --git a/src/sound_manager.c b/src/sound_manager.c index 7c74e7e..bc98ddc 100644 --- a/src/sound_manager.c +++ b/src/sound_manager.c @@ -199,7 +199,6 @@ int sound_manager_create_stream_information(sound_stream_type_e stream_type, sou memset(stream_h, 0, sizeof(sound_stream_info_s)); ret = _convert_stream_type(stream_type, &stream_h->stream_type); if (ret == MM_ERROR_NONE) { - _set_focus_availability(stream_h); ret = _make_pa_connection_and_register_focus(stream_h, callback, user_data); if (ret == MM_ERROR_NONE) { *stream_info = (sound_stream_info_h)stream_h; diff --git a/src/sound_manager_internal.c b/src/sound_manager_internal.c index d57964e..98f2f66 100644 --- a/src/sound_manager_internal.c +++ b/src/sound_manager_internal.c @@ -73,7 +73,6 @@ int sound_manager_create_stream_information_internal(sound_stream_type_internal_ LOGI(">> enter"); SM_NULL_ARG_CHECK(stream_info); - SM_NULL_ARG_CHECK(callback); SM_ENTER_CRITICAL_SECTION_WITH_RETURN(&g_stream_info_count_mutex, MM_ERROR_SOUND_INTERNAL); @@ -87,6 +86,10 @@ int sound_manager_create_stream_information_internal(sound_stream_type_internal_ ret = _convert_stream_type_for_internal(stream_type, &stream_h->stream_type); if (ret == MM_ERROR_NONE) { _set_focus_availability(stream_h); + if (!stream_h->is_focus_unavailable && !callback) { + ret = MM_ERROR_INVALID_ARGUMENT; + goto LEAVE; + } ret = _make_pa_connection_and_register_focus(stream_h, callback, user_data); if (!ret) { *stream_info = (sound_stream_info_h)stream_h; diff --git a/src/sound_manager_private.c b/src/sound_manager_private.c index 47db921..bcb2afe 100644 --- a/src/sound_manager_private.c +++ b/src/sound_manager_private.c @@ -1413,26 +1413,28 @@ int _make_pa_connection_and_register_focus(sound_stream_info_s *stream_h, sound_ pa_threaded_mainloop_unlock(stream_h->pa_mainloop); /* register focus */ - ret = mm_sound_register_focus(stream_h->index, stream_h->stream_type, _focus_state_change_callback, user_data); - if (ret == MM_ERROR_NONE) { - int i = 0; - stream_h->user_cb = callback; - stream_h->user_data = user_data; - for (i = 0; i < SOUND_STREAM_INFO_ARR_MAX; i++) { - if (sound_stream_info_arr[i] == NULL) { - sound_stream_info_arr[i] = stream_h; - break; + if (!stream_h->is_focus_unavailable) { + ret = mm_sound_register_focus(stream_h->index, stream_h->stream_type, _focus_state_change_callback, user_data); + if (ret == MM_ERROR_NONE) { + int i = 0; + stream_h->user_cb = callback; + stream_h->user_data = user_data; + for (i = 0; i < SOUND_STREAM_INFO_ARR_MAX; i++) { + if (sound_stream_info_arr[i] == NULL) { + sound_stream_info_arr[i] = stream_h; + break; + } } - } - if (i == SOUND_STREAM_INFO_ARR_MAX) { - LOGE("client sound stream info array is full"); - ret = mm_sound_unregister_focus(stream_h->index); + if (i == SOUND_STREAM_INFO_ARR_MAX) { + LOGE("client sound stream info array is full"); + ret = mm_sound_unregister_focus(stream_h->index); + goto PA_ERROR; + } + } else { + LOGE("failed to register focus, ret(0x%x)", ret); + /* disconnect */ goto PA_ERROR; } - } else { - LOGE("failed to register focus, ret(0x%x)", ret); - /* disconnect */ - goto PA_ERROR; } goto SUCCESS; PA_ERROR_WITH_UNLOCK: @@ -1497,9 +1499,11 @@ int _destroy_pa_connection_and_unregister_focus(sound_stream_info_s *stream_h) } /* unregister focus */ - ret = mm_sound_unregister_focus(stream_h->index); - if (ret) - LOGE("failed to unregister focus, ret(0x%x)", ret); + if (!stream_h->is_focus_unavailable) { + ret = mm_sound_unregister_focus(stream_h->index); + if (ret) + LOGE("failed to unregister focus, ret(0x%x)", ret); + } for (i = 0; i < AVAIL_DEVICES_MAX; i++) { if (stream_h->stream_conf_info.avail_in_devices[i]) diff --git a/test/sound_manager_test.c b/test/sound_manager_test.c index c7b7930..5be77b3 100644 --- a/test/sound_manager_test.c +++ b/test/sound_manager_test.c @@ -390,7 +390,7 @@ static void displaymenu() else if (g_menu_state == CURRENT_STATUS_UNSET_DEVICE_INFO_CHANGED_CB) g_print("*** press enter to unset device information changed cb\n"); else if (g_menu_state == CURRENT_STATUS_CREATE_STREAM_INFO) - g_print("*** input stream type to create stream information\n(0:media, 1:system, 2:alarm, 3:notification, 4:emergency, 5:ringtone-call, 6:voice-call, 7:voip, 8:media-ext-only, 9:loopback)\n"); + g_print("*** input stream type to create stream information\n(0:media, 1:system, 2:alarm, 3:notification, 4:emergency, 5:ringtone-call, 6:voice-call, 7:voip, 8:media-ext-only, 9:loopback, 10:solo)\n"); else if (g_menu_state == CURRENT_STATUS_ADD_DEVICE_FOR_STREAM_ROUTING) g_print("*** input device type to add (0:built-in mic, 1:built-in spk, 2:built-in rcv, 3:audio-jack, 4:bt, 5:usb)\n"); else if (g_menu_state == CURRENT_STATUS_REMOVE_DEVICE_FOR_STREAM_ROUTING) @@ -1029,6 +1029,9 @@ static void interpret(char *cmd) case 9: /* loopback */ type = SOUND_STREAM_TYPE_LOOPBACK; break; + case 10: /* solo */ + type = SOUND_STREAM_TYPE_SOLO; + break; default: type = SOUND_STREAM_TYPE_MEDIA; break; @@ -1037,6 +1040,8 @@ static void interpret(char *cmd) type == (int)SOUND_STREAM_TYPE_VOICE_CALL || type == (int)SOUND_STREAM_TYPE_LOOPBACK) ret = sound_manager_create_stream_information_internal(type, focus_callback, NULL, &g_stream_info_h); + else if (type == (int)SOUND_STREAM_TYPE_SOLO) + ret = sound_manager_create_stream_information_internal(type, NULL, NULL, &g_stream_info_h); else ret = sound_manager_create_stream_information(type, focus_callback, NULL, &g_stream_info_h);