Add more logs for debugging
[platform/core/multimedia/libmm-radio.git] / src / mm_radio_sound_focus.c
index 68760dc..696bc8f 100644 (file)
@@ -35,6 +35,7 @@ static void _mmradio_device_connected_cb(MMSoundDevice_t device, bool is_connect
 
        MMRADIO_LOG_FENTER();
        MMRADIO_CHECK_INSTANCE_RETURN_VOID(radio);
+       MMRADIO_LOG_INFO("device [%d] is_connected [%d]", device, is_connected);
 
        if (mm_sound_get_device_type(device, &type) != MM_ERROR_NONE) {
                MMRADIO_LOG_ERROR("getting device type failed");
@@ -52,7 +53,7 @@ static void _mmradio_device_connected_cb(MMSoundDevice_t device, bool is_connect
 
                                result = _mmradio_stop(radio);
                                if (result != MM_ERROR_NONE)
-                                       MMRADIO_LOG_ERROR("failed to stop radio\n");
+                                       MMRADIO_LOG_ERROR("failed to stop radio");
                        }
                        break;
                default:
@@ -67,7 +68,7 @@ void _mmradio_sound_signal_callback(mm_sound_signal_name_t signal, int value, vo
        mm_radio_sound_focus *sound_focus = (mm_radio_sound_focus *)user_data;
        int ret = MM_ERROR_NONE;
 
-       MMRADIO_LOG_DEBUG("sound signal callback %d / %d", signal, value);
+       MMRADIO_LOG_INFO("sound signal callback %d / %d", signal, value);
 
        if (signal == MM_SOUND_SIGNAL_RELEASE_INTERNAL_FOCUS) {
                if (value == 1) {
@@ -112,45 +113,45 @@ int mmradio_sound_focus_register(mm_radio_sound_focus *sound_focus,
        MMRADIO_LOG_FENTER();
 
        if (!sound_focus) {
-               MMRADIO_LOG_ERROR("invalid session handle\n");
+               MMRADIO_LOG_ERROR("invalid session handle");
                return MM_ERROR_RADIO_NOT_INITIALIZED;
        }
        sound_focus->cur_focus_type = FOCUS_NONE;
 
        /* read session information */
        ret = _mm_session_util_read_information(pid, &session_type, &session_flags);
-       MMRADIO_LOG_DEBUG("Read Session type ret:0x%X", ret);
+       MMRADIO_LOG_INFO("Read Session type ret:0x%X", ret);
        if (ret == MM_ERROR_INVALID_HANDLE) {
-               MMRADIO_LOG_WARNING("subscribe_id=%d\n", sound_focus->subscribe_id);
+               MMRADIO_LOG_WARNING("subscribe_id=%d", sound_focus->subscribe_id);
                if (sound_focus->subscribe_id == 0) {
                        ret = mm_sound_subscribe_signal_for_daemon(MM_SOUND_SIGNAL_RELEASE_INTERNAL_FOCUS, pid, &sound_focus->subscribe_id,
                                                                        (mm_sound_signal_callback)_mmradio_sound_signal_callback, (void*)sound_focus);
                        if (ret != MM_ERROR_NONE) {
-                               MMRADIO_LOG_ERROR("mm_sound_subscribe_signal is failed\n");
+                               MMRADIO_LOG_ERROR("mm_sound_subscribe_signal is failed");
                                return MM_ERROR_POLICY_BLOCKED;
                        }
-                       MMRADIO_LOG_DEBUG("register mm_sound_subscribe_signal_for_daemon subscribe_id %d\n", sound_focus->subscribe_id);
+                       MMRADIO_LOG_DEBUG("register mm_sound_subscribe_signal_for_daemon subscribe_id %d", sound_focus->subscribe_id);
                        /* register watch callback */
                        ret = mm_sound_set_focus_watch_callback_for_session(pid,
                                        FOCUS_FOR_BOTH, watch_cb, (void *)param, &sound_focus->watch_id);
                        if (ret != MM_ERROR_NONE) {
-                               MMRADIO_LOG_ERROR("mm_sound_set_focus_watch_callback is failed\n");
+                               MMRADIO_LOG_ERROR("mm_sound_set_focus_watch_callback is failed");
                                return MM_ERROR_POLICY_BLOCKED;
                        }
-                       MMRADIO_LOG_DEBUG("(%p) set focus watch callback = %d", param, sound_focus->watch_id);
+                       MMRADIO_LOG_INFO("(%p) set focus watch callback = %d", param, sound_focus->watch_id);
 
                        /* register device connected callback */
                        ret = mm_sound_add_device_connected_callback(MM_SOUND_DEVICE_TYPE_EXTERNAL_FLAG,
                                        (mm_sound_device_connected_cb)_mmradio_device_connected_cb, (void *)param, &sound_focus->device_subs_id);
                        if (ret != MM_ERROR_NONE) {
-                               MMRADIO_LOG_ERROR("mm_sound_add_device_connected_callback is failed\n");
+                               MMRADIO_LOG_ERROR("mm_sound_add_device_connected_callback is failed");
                                return MM_ERROR_POLICY_BLOCKED;
                        }
-                       MMRADIO_LOG_ERROR("register device connected callback for the value is 0, sub_cb id %d\n", sound_focus->device_subs_id);
+                       MMRADIO_LOG_INFO("register device connected callback for the value is 0, sub_cb id %d", sound_focus->device_subs_id);
                }
                ret = MM_ERROR_NONE;
        } else if (ret == MM_ERROR_NONE) {
-               MMRADIO_LOG_WARNING("Read Session Information success. session_type : %d flags: %d \n", session_type, session_flags);
+               MMRADIO_LOG_WARNING("Read Session Information success. session_type : %d flags: %d", session_type, session_flags);
                sound_focus->session_type = session_type;
                sound_focus->snd_session_flags = session_flags;
                if (sound_focus->session_type == MM_SESSION_TYPE_MEDIA) {
@@ -167,7 +168,7 @@ int mmradio_sound_focus_register(mm_radio_sound_focus *sound_focus,
 
                                ret = mm_sound_register_focus_for_session(handle, pid, "radio", focus_cb, param);
                                if (ret != MM_ERROR_NONE) {
-                                       MMRADIO_LOG_DEBUG("mm_sound_register_focus_for_session is failed\n");
+                                       MMRADIO_LOG_ERROR("mm_sound_register_focus_for_session is failed");
                                        return MM_ERROR_POLICY_BLOCKED;
                                }
                                MMRADIO_LOG_DEBUG("(%p) register focus for session %d", param, pid);
@@ -175,7 +176,7 @@ int mmradio_sound_focus_register(mm_radio_sound_focus *sound_focus,
                                ret = mm_sound_add_device_connected_callback(MM_SOUND_DEVICE_TYPE_EXTERNAL_FLAG,
                                        (mm_sound_device_connected_cb)_mmradio_device_connected_cb, (void *)param, &sound_focus->device_subs_id);
                                if (ret != MM_ERROR_NONE) {
-                                       MMRADIO_LOG_ERROR("mm_sound_add_device_connected_callback is failed\n");
+                                       MMRADIO_LOG_ERROR("mm_sound_add_device_connected_callback is failed");
                                        return MM_ERROR_POLICY_BLOCKED;
                                }
                                MMRADIO_LOG_DEBUG("(%p) add device connected callback = %d", param, sound_focus->device_subs_id);
@@ -185,7 +186,7 @@ int mmradio_sound_focus_register(mm_radio_sound_focus *sound_focus,
                                ret = mm_sound_add_device_connected_callback(MM_SOUND_DEVICE_TYPE_EXTERNAL_FLAG,
                                        (mm_sound_device_connected_cb)_mmradio_device_connected_cb, (void*)param, &sound_focus->device_subs_id);
                                if (ret != MM_ERROR_NONE) {
-                                       MMRADIO_LOG_ERROR("mm_sound_add_device_connected_callback is failed\n");
+                                       MMRADIO_LOG_ERROR("mm_sound_add_device_connected_callback is failed");
                                        return MM_ERROR_POLICY_BLOCKED;
                                }
                                MMRADIO_LOG_DEBUG("add device connected callback = %d", sound_focus->device_subs_id);
@@ -195,7 +196,7 @@ int mmradio_sound_focus_register(mm_radio_sound_focus *sound_focus,
                                ret = mm_sound_set_focus_watch_callback_for_session(pid,
                                                FOCUS_FOR_BOTH, watch_cb, (void*)param, &sound_focus->watch_id);
                                if (ret != MM_ERROR_NONE) {
-                                       MMRADIO_LOG_ERROR("mm_sound_set_focus_watch_callback is failed\n");
+                                       MMRADIO_LOG_ERROR("mm_sound_set_focus_watch_callback is failed");
                                        return MM_ERROR_POLICY_BLOCKED;
                                }
                                MMRADIO_LOG_DEBUG("set focus watch callback = %d", sound_focus->watch_id);
@@ -204,10 +205,10 @@ int mmradio_sound_focus_register(mm_radio_sound_focus *sound_focus,
                                ret = mm_sound_add_device_connected_callback(MM_SOUND_DEVICE_TYPE_EXTERNAL_FLAG,
                                                (mm_sound_device_connected_cb)_mmradio_device_connected_cb, (void*)param, &sound_focus->device_subs_id);
                                if (ret != MM_ERROR_NONE) {
-                                       MMRADIO_LOG_ERROR("mm_sound_add_device_connected_callback is failed\n");
+                                       MMRADIO_LOG_ERROR("mm_sound_add_device_connected_callback is failed");
                                        return MM_ERROR_POLICY_BLOCKED;
                                }
-                               MMRADIO_LOG_DEBUG("(%p) add device connected callback = %d", param, sound_focus->device_subs_id);
+                               MMRADIO_LOG_INFO("(%p) add device connected callback = %d", param, sound_focus->device_subs_id);
                        }
                } else if (sound_focus->session_type == MM_SESSION_TYPE_REPLACED_BY_STREAM) {
                        /* didn't register device connected cb */
@@ -218,7 +219,7 @@ int mmradio_sound_focus_register(mm_radio_sound_focus *sound_focus,
                }
                ret = MM_ERROR_NONE;
        } else {
-               MMRADIO_LOG_WARNING("Read Session Information failed. skip sound focus register function. errorcode %x \n", ret);
+               MMRADIO_LOG_WARNING("Read Session Information failed. skip sound focus register function. errorcode %x", ret);
        }
 
        MMRADIO_LOG_FLEAVE();
@@ -234,12 +235,12 @@ int mmradio_sound_focus_deregister(mm_radio_sound_focus *sound_focus)
        MMRADIO_LOG_FENTER();
 
        if (!sound_focus) {
-               MMRADIO_LOG_ERROR("invalid session handle\n");
+               MMRADIO_LOG_ERROR("invalid session handle");
                return MM_ERROR_RADIO_NOT_INITIALIZED;
        }
 
        if (sound_focus->watch_id > 0) {
-               MMRADIO_LOG_DEBUG("unset the focus watch cb %d", sound_focus->watch_id);
+               MMRADIO_LOG_INFO("unset the focus watch cb %d", sound_focus->watch_id);
 
                ret = mm_sound_unset_focus_watch_callback(sound_focus->watch_id);
                sound_focus->watch_id = 0;
@@ -255,7 +256,7 @@ int mmradio_sound_focus_deregister(mm_radio_sound_focus *sound_focus)
        }
        /* unregister device connected callback */
        if (sound_focus->device_subs_id > 0) {
-               MMRADIO_LOG_DEBUG("unset the device connected cb %d", sound_focus->device_subs_id);
+               MMRADIO_LOG_INFO("unset the device connected cb %d", sound_focus->device_subs_id);
                ret = mm_sound_remove_device_connected_callback(sound_focus->device_subs_id);
                sound_focus->device_subs_id = 0;
                if (ret != MM_ERROR_NONE)
@@ -263,7 +264,7 @@ int mmradio_sound_focus_deregister(mm_radio_sound_focus *sound_focus)
        }
 
        if (sound_focus->subscribe_id > 0) {
-               MMRADIO_LOG_DEBUG("unset mm_sound_subscribe_signal_for_daemon %d", sound_focus->subscribe_id);
+               MMRADIO_LOG_INFO("unset mm_sound_subscribe_signal_for_daemon %d", sound_focus->subscribe_id);
                mm_sound_unsubscribe_signal(sound_focus->subscribe_id);
        }
 
@@ -278,13 +279,13 @@ int mmradio_acquire_sound_focus(mm_radio_sound_focus *sound_focus)
        mm_sound_focus_type_e focus_type = FOCUS_NONE;
        MMRADIO_LOG_FENTER();
 
-       MMRADIO_LOG_ERROR("mmradio_acquire_sound_focus sound_focus->cur_focus_type : %d\n", sound_focus->cur_focus_type);
+       MMRADIO_LOG_ERROR("mmradio_acquire_sound_focus sound_focus->cur_focus_type : %d", sound_focus->cur_focus_type);
 
        focus_type = FOCUS_FOR_BOTH & ~(sound_focus->cur_focus_type);
        if (focus_type != FOCUS_NONE) {
                ret = mm_sound_acquire_focus(sound_focus->handle, focus_type, NULL);
                if (ret != MM_ERROR_NONE) {
-                       MMRADIO_LOG_ERROR("mm_sound_acquire_focus is failed\n");
+                       MMRADIO_LOG_ERROR("mm_sound_acquire_focus is failed");
                        return MM_ERROR_POLICY_BLOCKED;
                }
                sound_focus->cur_focus_type = FOCUS_FOR_BOTH;
@@ -299,11 +300,11 @@ int mmradio_release_sound_focus(mm_radio_sound_focus *sound_focus)
        int ret = MM_ERROR_NONE;
        MMRADIO_LOG_FENTER();
 
-       MMRADIO_LOG_ERROR("mmradio_release_sound_focus sound_focus->cur_focus_type : %d\n", sound_focus->cur_focus_type);
+       MMRADIO_LOG_ERROR("mmradio_release_sound_focus sound_focus->cur_focus_type : %d", sound_focus->cur_focus_type);
        if (sound_focus->cur_focus_type != FOCUS_NONE) {
                ret = mm_sound_release_focus(sound_focus->handle, sound_focus->cur_focus_type, NULL);
                if (ret != MM_ERROR_NONE) {
-                       MMRADIO_LOG_ERROR("mm_sound_release_focus is failed\n");
+                       MMRADIO_LOG_ERROR("mm_sound_release_focus is failed");
                        return MM_ERROR_POLICY_BLOCKED;
                }
                sound_focus->cur_focus_type = FOCUS_NONE;
@@ -318,7 +319,7 @@ int mmradio_release_sound_focus(mm_radio_sound_focus *sound_focus)
 void mmradio_get_sound_focus_reason(mm_sound_focus_state_e focus_state, const char *reason_for_change, bool is_watch, enum MMMessageInterruptedCode *event_source, int *postMsg)
 {
        MMRADIO_LOG_FENTER();
-       MMRADIO_LOG_ERROR("mmradio_get_sound_focus_reason focus_state : %d reason_for_change :%s\n", focus_state, reason_for_change);
+       MMRADIO_LOG_ERROR("mmradio_get_sound_focus_reason focus_state : %d reason_for_change :%s", focus_state, reason_for_change);
 
        if (0 == strncmp(reason_for_change, "call-voice", AUDIO_FOCUS_REASON_MAX)
                || (0 == strncmp(reason_for_change, "voip", AUDIO_FOCUS_REASON_MAX))