Allow NULL for sound_stream_focus_state_changed_cb which is a parameter of sound_mana... 16/85616/2 accepted/tizen/common/20160831.162106 accepted/tizen/ivi/20160901.065303 accepted/tizen/mobile/20160901.065042 accepted/tizen/tv/20160901.065139 accepted/tizen/wearable/20160901.065216 submit/tizen/20160831.052250
authorSangchul Lee <sc11.lee@samsung.com>
Fri, 26 Aug 2016 06:54:12 +0000 (15:54 +0900)
committerSangchul Lee <sc11.lee@samsung.com>
Mon, 29 Aug 2016 01:56:19 +0000 (10:56 +0900)
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 <sc11.lee@samsung.com>
include/sound_manager.h
packaging/capi-media-sound-manager.spec
src/sound_manager.c
src/sound_manager_internal.c

index d6200e1..7649fed 100644 (file)
@@ -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()
index 31d6ac1..364f59a 100755 (executable)
@@ -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
index d11117b..82b934a 100644 (file)
@@ -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) {
index 6d95a2b..e4c5bdd 100644 (file)
@@ -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;