diff options
author | Gilbok Lee <gilbok.lee@samsung.com> | 2017-06-07 21:29:27 +0900 |
---|---|---|
committer | Gilbok Lee <gilbok.lee@samsung.com> | 2017-06-07 21:29:27 +0900 |
commit | 9089a193386f93193f4641790d02cd7c335864bb (patch) | |
tree | b1684b4cca59dd0c32291678d594334758fab859 | |
parent | 04c6b15e4ab97af1ac388f2347e1005cceeff344 (diff) | |
download | libmm-radio-9089a193386f93193f4641790d02cd7c335864bb.tar.gz libmm-radio-9089a193386f93193f4641790d02cd7c335864bb.tar.bz2 libmm-radio-9089a193386f93193f4641790d02cd7c335864bb.zip |
Added implementation of interruption by resource manager in emulatorsubmit/tizen_4.0/20170828.110004submit/tizen_4.0/20170828.100004submit/tizen_4.0/20170811.094300submit/tizen/20170608.074715accepted/tizen/unified/20170608.184832accepted/tizen/4.0/unified/20170829.015845accepted/tizen/4.0/unified/20170816.010309
[Version] 0.2.28
[Profile] Mobile, Wearable
[Issue Type] Add features
Change-Id: I5280a82950db377c21b0938e7edf306ba9aa3d43
-rwxr-xr-x | packaging/libmm-radio.spec | 2 | ||||
-rw-r--r-- | src/include/mm_radio_priv.h | 2 | ||||
-rw-r--r-- | src/mm_radio_priv_emulator.c | 61 | ||||
-rw-r--r-- | src/mm_radio_resource.c | 4 |
4 files changed, 66 insertions, 3 deletions
diff --git a/packaging/libmm-radio.spec b/packaging/libmm-radio.spec index 1bbe61c..e1ce8d6 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.27 +Version: 0.2.28 Release: 0 Group: System/Libraries License: Apache-2.0 diff --git a/src/include/mm_radio_priv.h b/src/include/mm_radio_priv.h index 9e1eb3f..f45faac 100644 --- a/src/include/mm_radio_priv.h +++ b/src/include/mm_radio_priv.h @@ -39,6 +39,7 @@ #include "mm_radio.h" #include "mm_radio_utils.h" +#include "mm_radio_resource.h" #include <linux/videodev2.h> #include <gst/gst.h> @@ -190,6 +191,7 @@ typedef struct { #ifdef USE_GST_PIPELINE mm_radio_gstreamer_s* pGstreamer_s; #endif + mm_radio_resource_manager resource_manager; unsigned int subs_id; float local_volume; diff --git a/src/mm_radio_priv_emulator.c b/src/mm_radio_priv_emulator.c index 609f6a6..b82ed06 100644 --- a/src/mm_radio_priv_emulator.c +++ b/src/mm_radio_priv_emulator.c @@ -239,6 +239,13 @@ int _mmradio_create_radio(mm_radio_t * radio) MMRADIO_SET_STATE(radio, MM_RADIO_STATE_NULL); + /* initialize resource manager */ + ret = mmradio_resource_manager_init(&(radio->resource_manager), radio); + if (ret) { + MMRADIO_LOG_ERROR("failed to initialize resource manager\n"); + return MM_ERROR_RADIO_INTERNAL; + } + #ifdef TIZEN_FEATURE_SOUND_FOCUS /* register to audio focus */ ret = mmradio_sound_focus_register(&radio->sound_focus, @@ -366,6 +373,12 @@ int _mmradio_destroy(mm_radio_t * radio) } #endif + ret = mmradio_resource_manager_deinit(&radio->resource_manager); + if (ret) { + MMRADIO_LOG_ERROR("failed to initialize resource manager\n"); + return MM_ERROR_RADIO_INTERNAL; + } + MMRADIO_LOG_FLEAVE(); return MM_ERROR_NONE; @@ -577,6 +590,19 @@ int _mmradio_start(mm_radio_t * radio) MMRADIO_SLOG_DEBUG("now tune to frequency : %d\n", radio->freq); + ret = mmradio_resource_manager_prepare(&radio->resource_manager, MM_RADIO_RESOURCE_TYPE_RADIO); + if (ret != MM_ERROR_NONE) { + MMRADIO_LOG_ERROR("resource manager prepare fail"); + return MM_ERROR_RADIO_INTERNAL; + } + + ret = mmradio_resource_manager_acquire(&radio->resource_manager); + if (ret != MM_ERROR_NONE) { + MMRADIO_LOG_ERROR("failed to acquire resource manager"); + mmradio_resource_manager_unprepare(&radio->resource_manager); + return ret; + } + #ifdef TIZEN_FEATURE_SOUND_FOCUS if (radio->sound_focus.handle > 0) { ret = mmradio_acquire_sound_focus(&radio->sound_focus); @@ -637,6 +663,7 @@ int _mmradio_start(mm_radio_t * radio) int _mmradio_stop(mm_radio_t * radio) { int ret = MM_ERROR_NONE; + mm_radio_resource_state_e resource_state = MM_RADIO_RESOURCE_STATE_NONE; MMRADIO_LOG_FENTER(); @@ -646,6 +673,25 @@ int _mmradio_stop(mm_radio_t * radio) /* if( _mmradio_mute(radio) != MM_ERROR_NONE) */ /* return MM_ERROR_RADIO_NOT_INITIALIZED; */ + 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("resource manager unprepare fail"); + } + } + #ifdef TIZEN_FEATURE_SOUND_FOCUS if (radio->sound_focus.handle > 0) { ret = mmradio_release_sound_focus(&radio->sound_focus); @@ -1274,13 +1320,24 @@ static bool __mmradio_set_state(mm_radio_t * radio, int new_state) msg.state.code = radio->sound_focus.event_src; MMRADIO_POST_MSG(radio, msg_type, &msg); radio->sound_focus.by_focus_cb = false; + } else if (radio->resource_manager.by_rm_cb) { + msg_type = MM_MESSAGE_STATE_INTERRUPTED; + msg.state.code = MM_MSG_CODE_INTERRUPTED_BY_RESOURCE_CONFLICT; + MMRADIO_POST_MSG(radio, msg_type, &msg); } else { msg_type = MM_MESSAGE_STATE_CHANGED; MMRADIO_POST_MSG(radio, msg_type, &msg); } #else - msg_type = MM_MESSAGE_STATE_CHANGED; - MMRADIO_POST_MSG(radio, msg_type, &msg); + if (radio->resource_manager.by_rm_cb) { + msg_type = MM_MESSAGE_STATE_INTERRUPTED; + msg.state.code = MM_MSG_CODE_INTERRUPTED_BY_RESOURCE_CONFLICT; + MMRADIO_POST_MSG(radio, msg_type, &msg); + } else { + msg_type = MM_MESSAGE_STATE_CHANGED; + MMRADIO_POST_MSG(radio, msg_type, &msg); + } + #endif MMRADIO_LOG_FLEAVE(); diff --git a/src/mm_radio_resource.c b/src/mm_radio_resource.c index d474716..e87f8fa 100644 --- a/src/mm_radio_resource.c +++ b/src/mm_radio_resource.c @@ -18,7 +18,11 @@ */ #include "mm_radio_utils.h" +#ifdef TIZEN_FEATURE_RADIO_HAL #include "mm_radio_priv_hal.h" +#else +#include "mm_radio_priv.h" +#endif #include "mm_radio_resource.h" #include <murphy/common/glib-glue.h> |