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 15:57:19 +0900 |
commit | 849b12262d04198843c060e808a3b9275dc04a18 (patch) | |
tree | bfd08ba0d338dcd2dcf1b1d1f3ae3a54a524177a | |
parent | d4e48794c3077d6b0838762edabf94b4a29c7e3d (diff) | |
download | libmm-radio-849b12262d04198843c060e808a3b9275dc04a18.tar.gz libmm-radio-849b12262d04198843c060e808a3b9275dc04a18.tar.bz2 libmm-radio-849b12262d04198843c060e808a3b9275dc04a18.zip |
Radio device will be close, if radio device is opened when unrealize
[Version] 0.2.42
[Profile] Mobile, Wearable
[Issue Type] Fix bugs
Change-Id: I92e7068524b846380517c1abda2da9b391846daa
-rwxr-xr-x | packaging/libmm-radio.spec | 2 | ||||
-rw-r--r-- | src/mm_radio_priv_hal.c | 70 |
2 files changed, 44 insertions, 28 deletions
diff --git a/packaging/libmm-radio.spec b/packaging/libmm-radio.spec index 9657dc6..d85cf55 100755 --- 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.41 +Version: 0.2.42 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 24604b5..b11bc62 100644 --- a/src/mm_radio_priv_hal.c +++ b/src/mm_radio_priv_hal.c @@ -134,7 +134,7 @@ static int __resource_release_cb(mm_resource_manager_h rm, mm_resource_manager_res_h res, void *user_data); static void __mmradio_msg_thread(mm_radio_t *radio); 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, @@ -751,7 +751,6 @@ int _mmradio_stop(mm_radio_t *radio) if (ret != MM_RESOURCE_MANAGER_ERROR_NONE) MMRADIO_LOG_ERROR("resource manager commit fail"); } - radio->is_ready = false; } @@ -935,7 +934,6 @@ void __mmradio_scan_thread(mm_radio_t *radio) { int ret = MM_ERROR_NONE; int prev_freq = 0; - MMRadioThread_t *p_thread = NULL; MMRADIO_LOG_FENTER(); @@ -1068,29 +1066,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) - __convert_error_code(ret, (char *)__FUNCTION__); - - ret = radio_hal_unprepare(radio->hal_inf); - if (ret) - __convert_error_code(ret, (char *)__FUNCTION__); - - if (!radio->interrupted_by_resource_conflict && /* is being released */ - radio->radio_resource != NULL) { - ret = mm_resource_manager_mark_for_release(radio->resource_manager, - radio->radio_resource); - radio->radio_resource = NULL; - if (ret != MM_RESOURCE_MANAGER_ERROR_NONE) - MMRADIO_LOG_ERROR("failed to mark resource for release, ret(0x%x)", ret); - } - - ret = mm_resource_manager_commit(radio->resource_manager); - if (ret != MM_RESOURCE_MANAGER_ERROR_NONE) - MMRADIO_LOG_ERROR("resource manager commit fail"); - radio->is_ready = false; - } + __mmradio_close_radio_device(radio); MMRADIO_SET_STATE(radio, MM_RADIO_STATE_READY); } @@ -1107,6 +1083,9 @@ FINISHED_ERR: } EXIT: + /* close radio device here !!!! */ + __mmradio_close_radio_device(radio); + p_thread->is_running = false; MMRADIO_THREAD_UNLOCK(p_thread); @@ -1806,6 +1785,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(); @@ -1834,7 +1814,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); @@ -1883,3 +1862,40 @@ 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; + + 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) + __convert_error_code(ret, (char *)__FUNCTION__); + + ret = radio_hal_unprepare(radio->hal_inf); + if (ret) + __convert_error_code(ret, (char *)__FUNCTION__); + + if (!radio->interrupted_by_resource_conflict && /* is being released */ + radio->radio_resource != NULL) { + ret = mm_resource_manager_mark_for_release(radio->resource_manager, + radio->radio_resource); + radio->radio_resource = NULL; + if (ret != MM_RESOURCE_MANAGER_ERROR_NONE) + MMRADIO_LOG_ERROR("failed to mark resource for release, ret(0x%x)", ret); + } + + ret = mm_resource_manager_commit(radio->resource_manager); + if (ret != MM_RESOURCE_MANAGER_ERROR_NONE) + MMRADIO_LOG_ERROR("resource manager commit fail"); + + radio->is_ready = false; + +}
\ No newline at end of file |