diff options
author | Gilbok Lee <gilbok.lee@samsung.com> | 2018-08-20 16:56:46 +0900 |
---|---|---|
committer | Gilbok Lee <gilbok.lee@samsung.com> | 2018-08-21 11:57:59 +0900 |
commit | 59bd75835ed3fa8a0a6ded102dced504577af71c (patch) | |
tree | b206cbca4e7fd19dd27607e1c9ca25983b88f6c0 | |
parent | 9603f6b37a2d58af3e66d4a127818e4190a3dc67 (diff) | |
download | libmm-radio-submit/tizen_4.0/20180821.045220.tar.gz libmm-radio-submit/tizen_4.0/20180821.045220.tar.bz2 libmm-radio-submit/tizen_4.0/20180821.045220.zip |
Radio device will be close, if radio device is opened when unrealizesubmit/tizen_4.0/20180821.045220accepted/tizen/4.0/unified/20180829.004644
[Version] 0.2.39
[Profile] Mobile, Wearable
[Issue Type] Fix bugs
Change-Id: I92e7068524b846380517c1abda2da9b391846daa
-rw-r--r-- | packaging/libmm-radio.spec | 2 | ||||
-rw-r--r-- | src/mm_radio_priv_hal.c | 116 |
2 files changed, 67 insertions, 51 deletions
diff --git a/packaging/libmm-radio.spec b/packaging/libmm-radio.spec index b448c7a..00794f0 100644 --- a/packaging/libmm-radio.spec +++ b/packaging/libmm-radio.spec @@ -1,6 +1,6 @@ Name: libmm-radio Summary: Multimedia Framework Radio Library -Version: 0.2.38 +Version: 0.2.39 Release: 0 Group: System/Libraries License: Apache-2.0 diff --git a/src/mm_radio_priv_hal.c b/src/mm_radio_priv_hal.c index f509b27..7d71787 100644 --- a/src/mm_radio_priv_hal.c +++ b/src/mm_radio_priv_hal.c @@ -140,7 +140,7 @@ static void __mmradio_msg_thread(mm_radio_t *radio); static void __mmradio_volume_changed_cb(volume_type_t type, unsigned int volume, void *user_data); static int __mmradio_set_media_volume(mm_radio_t *radio, unsigned int level); static void __mmradio_msg_push(mm_radio_t *radio, MMRadioMsgTypes msg_type, int msg_data); - +static void __mmradio_close_radio_device(mm_radio_t *radio); typedef void (*thread_function)(mm_radio_t *); thread_function __mmradio_thread_function[] = { &__mmradio_msg_thread, @@ -734,26 +734,26 @@ int _mmradio_stop(mm_radio_t *radio) return ret; } - radio->is_ready = false; - } - - if (!radio->resource_manager.by_rm_cb && /* is being released */ - mmradio_resource_manager_get_state(&radio->resource_manager, &resource_state) == MM_ERROR_NONE) { - if (resource_state == MM_RADIO_RESOURCE_STATE_ACQUIRED) { - ret = mmradio_resource_manager_release(&radio->resource_manager); - if (ret != MM_ERROR_NONE) { - MMRADIO_LOG_ERROR("failed to release resource, ret(0x%x)", ret); - return ret; + if (!radio->resource_manager.by_rm_cb && /* is being released */ + mmradio_resource_manager_get_state(&radio->resource_manager, &resource_state) == MM_ERROR_NONE) { + if (resource_state == MM_RADIO_RESOURCE_STATE_ACQUIRED) { + ret = mmradio_resource_manager_release(&radio->resource_manager); + if (ret != MM_ERROR_NONE) { + MMRADIO_LOG_ERROR("failed to release resource, ret(0x%x)", ret); + return ret; + } } } - } - if (mmradio_resource_manager_get_state(&radio->resource_manager, &resource_state) == MM_ERROR_NONE) { - if (resource_state == MM_RADIO_RESOURCE_STATE_PREPARED) { - ret = mmradio_resource_manager_unprepare(&radio->resource_manager); - if (ret != MM_ERROR_NONE) - MMRADIO_LOG_ERROR("failed to unprepare resource manager"); + if (mmradio_resource_manager_get_state(&radio->resource_manager, &resource_state) == MM_ERROR_NONE) { + if (resource_state == MM_RADIO_RESOURCE_STATE_PREPARED) { + ret = mmradio_resource_manager_unprepare(&radio->resource_manager); + if (ret != MM_ERROR_NONE) + MMRADIO_LOG_ERROR("failed to unprepare resource manager"); + } } + + radio->is_ready = false; } #ifdef TIZEN_FEATURE_SOUND_FOCUS @@ -929,7 +929,6 @@ void __mmradio_scan_thread(mm_radio_t *radio) { int ret = MM_ERROR_NONE; int prev_freq = 0; - mm_radio_resource_state_e resource_state = MM_RADIO_RESOURCE_STATE_NONE; MMRadioThread_t *p_thread = NULL; MMRADIO_LOG_FENTER(); @@ -1058,37 +1057,7 @@ FINISHED_ERR: MMRADIO_SET_STATE(radio, MM_RADIO_STATE_PLAYING); } else { /* close radio device here !!!! */ - if (radio->is_ready) { - ret = radio_hal_close(radio->hal_inf); - if (ret == MM_ERROR_NOT_SUPPORT_API) - MMRADIO_LOG_WARNING("radio_hal_close is not supported"); - else if (ret != MM_ERROR_NONE) - MMRADIO_LOG_ERROR("failed to close radio hal"); - - ret = radio_hal_unprepare(radio->hal_inf); - if (ret == MM_ERROR_NOT_SUPPORT_API) - MMRADIO_LOG_WARNING("radio_hal_unprepare is not supported"); - else if (ret != MM_ERROR_NONE) - MMRADIO_LOG_ERROR("failed to unprepare radio hal"); - - if (!radio->resource_manager.by_rm_cb && /* is being released */ - mmradio_resource_manager_get_state(&radio->resource_manager, &resource_state) == MM_ERROR_NONE) { - if (resource_state == MM_RADIO_RESOURCE_STATE_ACQUIRED) { - ret = mmradio_resource_manager_release(&radio->resource_manager); - if (ret != MM_ERROR_NONE) - MMRADIO_LOG_ERROR("failed to release resource, ret(0x%x)", ret); - } - } - - if (mmradio_resource_manager_get_state(&radio->resource_manager, &resource_state) == MM_ERROR_NONE) { - if (resource_state == MM_RADIO_RESOURCE_STATE_PREPARED) { - ret = mmradio_resource_manager_unprepare(&radio->resource_manager); - if (ret != MM_ERROR_NONE) - MMRADIO_LOG_ERROR("failed to unprepare resource manager"); - } - } - radio->is_ready = false; - } + __mmradio_close_radio_device(radio); MMRADIO_SET_STATE(radio, MM_RADIO_STATE_READY); } @@ -1105,6 +1074,9 @@ FINISHED_ERR: } EXIT: + /* close radio device here !!!! */ + __mmradio_close_radio_device(radio); + p_thread->is_running = false; MMRADIO_THREAD_UNLOCK(p_thread); @@ -1869,6 +1841,7 @@ void __mmradio_msg_thread(mm_radio_t *radio) { mm_radio_msg_t *msg = NULL; + mm_radio_msg_t *msg_pop = NULL; MMRadioThread_t *p_thread = NULL; MMRADIO_LOG_FENTER(); @@ -1897,7 +1870,6 @@ void __mmradio_msg_thread(mm_radio_t *radio) switch (msg->msg_type) { case MM_RADIO_MSG_DESTROY: MMRADIO_LOG_INFO("get destroy msg. pop all event to finish this thread"); - mm_radio_msg_t *msg_pop = NULL; while ((msg_pop = (mm_radio_msg_t *)g_async_queue_try_pop(radio->msg_queue))) { if (msg_pop != NULL) { MMRADIO_LOG_DEBUG("drop this msg type: %d", msg_pop->msg_type); @@ -1952,3 +1924,47 @@ void __mmradio_msg_thread(mm_radio_t *radio) MMRADIO_LOG_FLEAVE(); pthread_exit(NULL); } + +static void __mmradio_close_radio_device(mm_radio_t *radio) +{ + int ret = MM_ERROR_NONE; + mm_radio_resource_state_e resource_state = MM_RADIO_RESOURCE_STATE_NONE; + + MMRADIO_LOG_FENTER(); + MMRADIO_CHECK_INSTANCE_RETURN_VOID(radio); + + if (!radio->is_ready) { + MMRADIO_LOG_DEBUG("radio device is already closed"); + return; + } + + ret = radio_hal_close(radio->hal_inf); + if (ret == MM_ERROR_NOT_SUPPORT_API) + MMRADIO_LOG_WARNING("radio_hal_close is not supported"); + else if (ret != MM_ERROR_NONE) + MMRADIO_LOG_ERROR("failed to close radio hal"); + + ret = radio_hal_unprepare(radio->hal_inf); + if (ret == MM_ERROR_NOT_SUPPORT_API) + MMRADIO_LOG_WARNING("radio_hal_unprepare is not supported"); + else if (ret != MM_ERROR_NONE) + MMRADIO_LOG_ERROR("failed to unprepare radio hal"); + + if (!radio->resource_manager.by_rm_cb && /* is being released */ + mmradio_resource_manager_get_state(&radio->resource_manager, &resource_state) == MM_ERROR_NONE) { + if (resource_state == MM_RADIO_RESOURCE_STATE_ACQUIRED) { + ret = mmradio_resource_manager_release(&radio->resource_manager); + if (ret != MM_ERROR_NONE) + MMRADIO_LOG_ERROR("failed to release resource, ret(0x%x)", ret); + } + } + + if (mmradio_resource_manager_get_state(&radio->resource_manager, &resource_state) == MM_ERROR_NONE) { + if (resource_state == MM_RADIO_RESOURCE_STATE_PREPARED) { + ret = mmradio_resource_manager_unprepare(&radio->resource_manager); + if (ret != MM_ERROR_NONE) + MMRADIO_LOG_ERROR("failed to unprepare resource manager"); + } + } + radio->is_ready = false; +}
\ No newline at end of file |