From: Sangchul Lee Date: Fri, 26 Aug 2016 06:54:12 +0000 (+0900) Subject: Allow NULL for sound_stream_focus_state_changed_cb which is a parameter of sound_mana... X-Git-Tag: accepted/tizen/common/20160831.162106^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ff6a7a461b337a2e467005d0869fe5ace562c173;p=platform%2Fcore%2Fapi%2Fsound-manager.git Allow NULL for sound_stream_focus_state_changed_cb which is a parameter of sound_manager_create_stream_information() If it is set to NULL, SOUND_MANAGER_ERROR_POLICY will be returned when calling sound_manager_acquire_focus(). [Version] Release 0.3.62 [Profile] Common [Issue Type] Policy Change-Id: I725d6227580327ac529fe572009747501446a91b Signed-off-by: Sangchul Lee --- diff --git a/include/sound_manager.h b/include/sound_manager.h index d6200e1..7649fed 100644 --- a/include/sound_manager.h +++ b/include/sound_manager.h @@ -566,8 +566,8 @@ int sound_manager_unset_volume_changed_cb(void); * related to playback or recording.(e.g. player, wav-player, audio-io, etc.) * * @param[in] stream_type The type of stream - * @param[in] callback The focus state change callback function (mandatory) - * @param[in] user_data The user data to be passed to the callback function + * @param[in] callback The focus state change callback function (optional, this can be null) + * @param[in] user_data The user data to be passed to the callback function (optional, this can be null) * @param[out] stream_info The handle of stream information * @return @c 0 on success, * otherwise a negative error value @@ -694,7 +694,7 @@ int sound_manager_apply_stream_routing(sound_stream_info_h stream_info); * @retval #SOUND_MANAGER_ERROR_INVALID_STATE Invalid state * @retval #SOUND_MANAGER_ERROR_POLICY Noncompliance with the sound system policy * @retval #SOUND_MANAGER_ERROR_INTERNAL Internal error inside the sound system - * @pre Call sound_manager_create_stream_information() before calling this function. + * @pre Call sound_manager_create_stream_information() with its parameter for sound_stream_focus_state_changed_cb before calling this function. * @see sound_manager_create_stream_information() * @see sound_manager_destroy_stream_information() * @see sound_manager_release_focus() diff --git a/packaging/capi-media-sound-manager.spec b/packaging/capi-media-sound-manager.spec index 31d6ac1..364f59a 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.61 +Version: 0.3.62 Release: 0 Group: Multimedia/API License: Apache-2.0 diff --git a/src/sound_manager.c b/src/sound_manager.c index d11117b..82b934a 100644 --- a/src/sound_manager.c +++ b/src/sound_manager.c @@ -183,7 +183,6 @@ int sound_manager_create_stream_information(sound_stream_type_e stream_type, sou LOGI(">> enter"); SM_NULL_ARG_CHECK(stream_info); - SM_NULL_ARG_CHECK(callback); if (g_session_interrupt_cb_table.is_registered) return _convert_sound_manager_error_code(__func__, MM_ERROR_SOUND_INTERNAL); @@ -313,8 +312,15 @@ int sound_manager_acquire_focus(sound_stream_info_h stream_info, sound_stream_fo SM_INSTANCE_CHECK(stream_h); - if (stream_h->is_focus_unavailable) + if (stream_h->is_focus_unavailable) { + LOGE("acquiring focus is not allowed for this strema type(%s)", stream_h->stream_type); return _convert_sound_manager_error_code(__func__, MM_ERROR_POLICY_INTERNAL); + } + + if (stream_h->user_cb == NULL) { + LOGE("focus state changed callback should be set before acquiring focus"); + return _convert_sound_manager_error_code(__func__, MM_ERROR_POLICY_INTERNAL); + } ret = mm_sound_acquire_focus(stream_h->index, (mm_sound_focus_type_e)focus_mask, extra_info); if (ret == MM_ERROR_NONE) { diff --git a/src/sound_manager_internal.c b/src/sound_manager_internal.c index 6d95a2b..e4c5bdd 100644 --- a/src/sound_manager_internal.c +++ b/src/sound_manager_internal.c @@ -88,10 +88,6 @@ 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;