Add condition not to check argument of focus callback in case of sound_manager_create... 28/63628/1 accepted/tizen/common/20160325.135731 accepted/tizen/ivi/20160325.072817 accepted/tizen/mobile/20160325.072647 accepted/tizen/tv/20160325.072721 accepted/tizen/wearable/20160325.072748 submit/tizen/20160325.051148
authorSangchul Lee <sc11.lee@samsung.com>
Fri, 25 Mar 2016 03:15:30 +0000 (12:15 +0900)
committerSangchul Lee <sc11.lee@samsung.com>
Fri, 25 Mar 2016 04:42:38 +0000 (13:42 +0900)
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 <sc11.lee@samsung.com>
include/sound_manager_internal.h
packaging/capi-media-sound-manager.spec
src/sound_manager.c
src/sound_manager_internal.c
src/sound_manager_private.c
test/sound_manager_test.c

index dd021083b6096a31b04b0113e61d9ce63d67f435..50ca8c41535e15f0b14f4251a481f08334b8f7d4 100644 (file)
@@ -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
  *
index 257d3acf9267eb09cbc7ad03a686b6ad51b3f9ed..5df7c95b20e68979f1435096d7d62e746a7cb572 100755 (executable)
@@ -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
index 7c74e7e674b1bf7a216cda3220bcc5b52759bc41..bc98ddc8f3fc2393843313b93a4bfb4b1e627bd3 100644 (file)
@@ -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;
index d57964e4442e091f0e2f3b574ac7321de1791956..98f2f66dcb4bb921171a7916e04bae468d2f9e04 100644 (file)
@@ -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;
index 47db921c01f1b40304e8b5f9de9d9a4c7995bd84..bcb2afe82c400fda1e0f6a2c00fac0940a2bed72 100644 (file)
@@ -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])
index c7b7930a4d40dabfeddfaf5f3f89529c356c1ee8..5be77b3a97c7af76176d2d4aedc200ad1c0f84ea 100644 (file)
@@ -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);