diff options
author | Gilbok Lee <gilbok.lee@samsung.com> | 2017-02-20 20:33:12 +0900 |
---|---|---|
committer | Gilbok Lee <gilbok.lee@samsung.com> | 2017-02-20 20:33:12 +0900 |
commit | 6ebdd69081e06c5888eefe785f0c2c37062c483f (patch) | |
tree | bec89585bfcd3622a54fa440b91883abae758d9b /src | |
parent | 684952d47398be7a40eb4a0137a307ccefc32cf7 (diff) | |
download | libmm-radio-6ebdd69081e06c5888eefe785f0c2c37062c483f.tar.gz libmm-radio-6ebdd69081e06c5888eefe785f0c2c37062c483f.tar.bz2 libmm-radio-6ebdd69081e06c5888eefe785f0c2c37062c483f.zip |
Add more logs for debugging
[Version] 0.2.21
[Profile] Mobile, Wearable
[Issue Type] Add log
Change-Id: Id832b06d265300d31ea918cc4a7bfb67bf7929f5
Diffstat (limited to 'src')
-rw-r--r-- | src/include/mm_radio_utils.h | 1 | ||||
-rw-r--r-- | src/mm_radio.c | 6 | ||||
-rw-r--r-- | src/mm_radio_priv_hal.c | 60 | ||||
-rw-r--r-- | src/mm_radio_sound_focus.c | 19 |
4 files changed, 53 insertions, 33 deletions
diff --git a/src/include/mm_radio_utils.h b/src/include/mm_radio_utils.h index d368a60..3f70f29 100644 --- a/src/include/mm_radio_utils.h +++ b/src/include/mm_radio_utils.h @@ -29,6 +29,7 @@ /* radio log */ #define MMRADIO_LOG_FENTER debug_fenter #define MMRADIO_LOG_FLEAVE debug_fleave +#define MMRADIO_LOG_INFO debug_msg #define MMRADIO_LOG_DEBUG debug_log #define MMRADIO_LOG_ERROR debug_error #define MMRADIO_LOG_WARNING debug_warning diff --git a/src/mm_radio.c b/src/mm_radio.c index 62cd24b..becf05d 100644 --- a/src/mm_radio.c +++ b/src/mm_radio.c @@ -104,8 +104,10 @@ int mm_radio_create(MMHandleType *hradio) /* internal creation stuffs */ result = _mmradio_create_radio(new_radio); - if (result != MM_ERROR_NONE) + if (result != MM_ERROR_NONE) { + debug_error("radio creation failed\n"); goto ERROR; + } *hradio = (MMHandleType)new_radio; @@ -426,7 +428,7 @@ int mm_radio_get_signal_strength(MMHandleType hradio, int *value) MMRADIO_CMD_UNLOCK(radio); - MMRADIO_LOG_DEBUG("signal strength = %d\n", *value); + MMRADIO_LOG_INFO("signal strength = %d\n", *value); MMRADIO_LOG_FLEAVE(); return ret; diff --git a/src/mm_radio_priv_hal.c b/src/mm_radio_priv_hal.c index ae5bca3..82afebb 100644 --- a/src/mm_radio_priv_hal.c +++ b/src/mm_radio_priv_hal.c @@ -169,7 +169,7 @@ int _mmradio_apply_region(mm_radio_t *radio, MMRadioRegionType region, bool upda } } - MMRADIO_LOG_DEBUG("setting region - country: %d, de-emphasis: %d, band range: %d ~ %d KHz", + MMRADIO_LOG_INFO("setting region - country: %d, de-emphasis: %d, band range: %d ~ %d KHz", radio->region_setting.country, radio->region_setting.deemphasis, radio->region_setting.band_min, radio->region_setting.band_max); @@ -249,7 +249,7 @@ int _mmradio_realize(mm_radio_t *radio) ret = pthread_mutex_init(&radio->seek_cancel_mutex, NULL); if (ret < 0) { - MMRADIO_LOG_DEBUG("Mutex creation failed %d", ret); + MMRADIO_LOG_ERROR("Mutex creation failed %d", ret); return MM_ERROR_RADIO_INTERNAL; } @@ -357,6 +357,18 @@ int _mmradio_destroy(mm_radio_t *radio) MMRADIO_LOG_ERROR("mmradio hal interface deinit failed"); return ret; } + + /* destroy command lock */ + ret = pthread_mutex_destroy(&radio->cmd_lock); + if (ret) { + MMRADIO_LOG_ERROR("mutex destroy failed\n"); + } + + ret = pthread_mutex_destroy(&radio->volume_lock); + if (ret) { + MMRADIO_LOG_ERROR("volume mutex destroy failed\n"); + } + #ifdef TIZEN_FEATURE_SOUND_FOCUS ret = mmradio_sound_focus_deregister(&radio->sound_focus); if (ret) { @@ -379,7 +391,7 @@ int _mmradio_set_frequency(mm_radio_t *radio, int freq) MMRADIO_CHECK_INSTANCE(radio); MMRADIO_CHECK_STATE_RETURN_IF_FAIL(radio, MMRADIO_COMMAND_SET_FREQ); - MMRADIO_LOG_DEBUG("Setting %d frequency", freq); + MMRADIO_LOG_INFO("Setting %d frequency", freq); radio->freq = freq; @@ -415,6 +427,7 @@ int _mmradio_get_frequency(mm_radio_t *radio, int *pFreq) } /* update freq in handle */ + MMRADIO_LOG_INFO("Updating %d frequency", freq); radio->freq = freq; *pFreq = (int)radio->freq; @@ -442,6 +455,7 @@ int _mmradio_mute(mm_radio_t *radio) } radio->is_muted = TRUE; + MMRADIO_LOG_INFO("Radio mute state [%d]", radio->is_muted); MMRADIO_LOG_FLEAVE(); return ret; @@ -465,7 +479,7 @@ int _mmradio_unmute(mm_radio_t *radio) } radio->is_muted = FALSE; - + MMRADIO_LOG_INFO("Radio mute state [%d]", radio->is_muted); MMRADIO_LOG_FLEAVE(); return ret; @@ -515,7 +529,7 @@ int _mmradio_start(mm_radio_t *radio) MMRADIO_CHECK_INSTANCE(radio); MMRADIO_CHECK_STATE_RETURN_IF_FAIL(radio, MMRADIO_COMMAND_START); - MMRADIO_LOG_DEBUG("now tune to frequency : %d", radio->freq); + MMRADIO_LOG_INFO("now tune to frequency : %d", radio->freq); #ifdef TIZEN_FEATURE_SOUND_FOCUS if (radio->sound_focus.handle > 0) { @@ -691,7 +705,7 @@ int _mmradio_seek(mm_radio_t *radio, MMRadioSeekDirectionType direction) radio->seek_unmute = TRUE; } - MMRADIO_LOG_DEBUG("trying to seek. direction[0:UP/1:DOWN) %d", direction); + MMRADIO_LOG_INFO("trying to seek. direction[0:UP/1:DOWN) %d", direction); radio->seek_direction = direction; ret = pthread_create(&radio->seek_thread, NULL, (void *)__mmradio_seek_thread, (void *)radio); @@ -732,9 +746,9 @@ void _mmradio_seek_cancel(mm_radio_t *radio) ret = pthread_mutex_trylock(&radio->seek_cancel_mutex); MMRADIO_LOG_DEBUG("try lock ret: %s (%d)", strerror_r(ret, str_error, sizeof(str_error)), ret); if (ret == EBUSY) { /* it was already locked by other */ - MMRADIO_LOG_DEBUG("send SEEK ABORT with FMRX_PROPERTY_SEARCH_ABORT"); + MMRADIO_LOG_WARNING("send SEEK ABORT with FMRX_PROPERTY_SEARCH_ABORT"); } else if (ret == 0) { - MMRADIO_LOG_DEBUG("trylock is successful. unlock now"); + MMRADIO_LOG_INFO("trylock is successful. unlock now"); pthread_mutex_unlock(&radio->seek_cancel_mutex); } else { MMRADIO_LOG_ERROR("trylock is failed but Not EBUSY. ret: %d", ret); @@ -787,7 +801,7 @@ int _mmradio_start_scan(mm_radio_t *radio) scan_tr_id = pthread_create(&radio->scan_thread, NULL, (void *)__mmradio_scan_thread, (void *)radio); if (scan_tr_id != 0) { - MMRADIO_LOG_DEBUG("failed to create thread : scan"); + MMRADIO_LOG_ERROR("failed to create thread : scan"); return MM_ERROR_RADIO_NOT_INITIALIZED; } @@ -814,9 +828,9 @@ int _mmradio_stop_scan(mm_radio_t *radio) ret = pthread_mutex_trylock(&radio->seek_cancel_mutex); MMRADIO_LOG_DEBUG("try lock ret: %s (%d)", strerror_r(ret, str_error, sizeof(str_error)), ret); if (ret == EBUSY) { /* it was already locked by other */ - MMRADIO_LOG_DEBUG("send SEEK ABORT with FMRX_PROPERTY_SEARCH_ABORT"); + MMRADIO_LOG_WARNING("send SEEK ABORT with FMRX_PROPERTY_SEARCH_ABORT"); } else if (ret == 0) { - MMRADIO_LOG_DEBUG("trylock is successful. unlock now"); + MMRADIO_LOG_INFO("trylock is successful. unlock now"); pthread_mutex_unlock(&radio->seek_cancel_mutex); } else { MMRADIO_LOG_ERROR("trylock is failed but Not EBUSY. ret: %d", ret); @@ -888,7 +902,7 @@ void __mmradio_scan_thread(mm_radio_t *radio) pthread_mutex_lock(&radio->seek_cancel_mutex); if (radio->stop_scan) { - MMRADIO_LOG_DEBUG("scan was canceled"); + MMRADIO_LOG_INFO("scan was canceled"); pthread_mutex_unlock(&radio->seek_cancel_mutex); goto FINISHED; } @@ -919,11 +933,11 @@ void __mmradio_scan_thread(mm_radio_t *radio) continue; prev_freq = param.radio_scan.frequency = (int)freq; - MMRADIO_LOG_DEBUG("scanning : new frequency : [%d]", param.radio_scan.frequency); + MMRADIO_LOG_INFO("scanning : new frequency : [%d]", param.radio_scan.frequency); /* drop if max freq is scanned */ if (param.radio_scan.frequency == radio->region_setting.band_max) { - MMRADIO_LOG_DEBUG("%d freq is dropping...and stopping scan", param.radio_scan.frequency); + MMRADIO_LOG_WARNING("%d freq is dropping...and stopping scan", param.radio_scan.frequency); break; } @@ -1028,7 +1042,7 @@ void __mmradio_seek_thread(mm_radio_t *radio) MMRADIO_LOG_DEBUG("seek start"); if (radio->seek_cancel) { - MMRADIO_LOG_DEBUG("seek was canceled so we return failure to application"); + MMRADIO_LOG_INFO("seek was canceled so we return failure to application"); pthread_mutex_unlock(&radio->seek_cancel_mutex); goto SEEK_FAILED; } @@ -1051,7 +1065,7 @@ void __mmradio_seek_thread(mm_radio_t *radio) /* if same freq is found, ignore it and search next one. */ if (freq == radio->prev_seek_freq) { - MMRADIO_LOG_DEBUG("It's same with previous found one. So, trying next one."); + MMRADIO_LOG_WARNING("It's same with previous found one. So, trying next one."); goto SEEK_FAILED; } @@ -1079,7 +1093,7 @@ void __mmradio_seek_thread(mm_radio_t *radio) } param.radio_scan.frequency = radio->prev_seek_freq = (int)freq; - MMRADIO_LOG_DEBUG("seeking : new frequency : [%d]", param.radio_scan.frequency); + MMRADIO_LOG_INFO("seeking : new frequency : [%d]", param.radio_scan.frequency); MMRADIO_POST_MSG(radio, MM_MESSAGE_RADIO_SEEK_FINISH, ¶m); } @@ -1141,7 +1155,7 @@ static int __mmradio_check_state(mm_radio_t *radio, MMRadioCommand command) radio_state = __mmradio_get_state(radio); - MMRADIO_LOG_DEBUG("incomming command : %d current state : %d", command, radio_state); + MMRADIO_LOG_INFO("incomming command : %d current state : %d", command, radio_state); switch (command) { case MMRADIO_COMMAND_CREATE: @@ -1326,7 +1340,7 @@ static int __mmradio_get_state(mm_radio_t *radio) { MMRADIO_CHECK_INSTANCE(radio); - MMRADIO_LOG_DEBUG("radio state : current : [%d] old : [%d] pending : [%d]", + MMRADIO_LOG_INFO("radio state : current : [%d] old : [%d] pending : [%d]", radio->current_state, radio->old_state, radio->pending_state); return radio->current_state; @@ -1344,6 +1358,7 @@ static void __mmradio_sound_focus_cb(int id, mm_sound_focus_type_e focus_type, MMRADIO_LOG_FENTER(); MMRADIO_CHECK_INSTANCE_RETURN_VOID(radio); + MMRADIO_LOG_INFO("focus_state [%d]", focus_state); mmradio_get_sound_focus_reason(focus_state, reason_for_change, FALSE, &event_source, &postMsg); radio->sound_focus.event_src = event_source; @@ -1396,6 +1411,7 @@ static void __mmradio_sound_focus_watch_cb(int id, mm_sound_focus_type_e focus_t MMRADIO_LOG_FENTER(); MMRADIO_CHECK_INSTANCE_RETURN_VOID(radio); + MMRADIO_LOG_INFO("focus_state [%d]", focus_state); mmradio_get_sound_focus_reason(focus_state, reason_for_change, TRUE, &event_source, &postMsg); radio->sound_focus.event_src = event_source; @@ -1444,7 +1460,7 @@ static void __mmradio_volume_changed_cb(volume_type_t type, unsigned int volume, int ret = MM_ERROR_NONE; MMRADIO_CHECK_INSTANCE_RETURN_VOID(radio); if (type == VOLUME_TYPE_MEDIA) { - MMRADIO_LOG_DEBUG("Change FM Radio volume to %d", volume); + MMRADIO_LOG_INFO("Change FM Radio volume to %d", volume); ret = __mmradio_set_media_volume(radio, volume); if (ret != MM_ERROR_NONE) MMRADIO_LOG_ERROR("__mmradio_set_media_volume error"); @@ -1504,7 +1520,7 @@ int _mmradio_set_volume(mm_radio_t *radio, float volume) MMRADIO_CHECK_INSTANCE(radio); MMRADIO_CHECK_STATE_RETURN_IF_FAIL(radio, MMRADIO_COMMAND_SET_VOLUME); - MMRADIO_LOG_DEBUG("Setting %f volume", volume); + MMRADIO_LOG_INFO("Setting %f volume", volume); MMRADIO_VOLUME_LOCK(radio); radio->local_volume = volume; @@ -1556,7 +1572,7 @@ static int __mmradio_set_media_volume(mm_radio_t *radio, unsigned int level) MMRADIO_CHECK_INSTANCE(radio); MMRADIO_CHECK_STATE_RETURN_IF_FAIL(radio, MMRADIO_COMMAND_SET_VOLUME); - MMRADIO_LOG_DEBUG("Setting %d volume", level); + MMRADIO_LOG_INFO("Setting %d volume", level); MMRADIO_VOLUME_LOCK(radio); radio->media_volume = level; diff --git a/src/mm_radio_sound_focus.c b/src/mm_radio_sound_focus.c index 668c060..696bc8f 100644 --- a/src/mm_radio_sound_focus.c +++ b/src/mm_radio_sound_focus.c @@ -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"); @@ -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) { @@ -119,7 +120,7 @@ int mmradio_sound_focus_register(mm_radio_sound_focus *sound_focus, /* 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", sound_focus->subscribe_id); if (sound_focus->subscribe_id == 0) { @@ -137,7 +138,7 @@ int mmradio_sound_focus_register(mm_radio_sound_focus *sound_focus, 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, @@ -146,7 +147,7 @@ int mmradio_sound_focus_register(mm_radio_sound_focus *sound_focus, 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", 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) { @@ -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"); + 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); @@ -207,7 +208,7 @@ int mmradio_sound_focus_register(mm_radio_sound_focus *sound_focus, 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 */ @@ -239,7 +240,7 @@ int mmradio_sound_focus_deregister(mm_radio_sound_focus *sound_focus) } 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); } |