diff options
author | Gilbok Lee <gilbok.lee@samsung.com> | 2017-04-10 13:17:41 +0900 |
---|---|---|
committer | Gilbok Lee <gilbok.lee@samsung.com> | 2017-04-10 16:41:05 +0900 |
commit | 42e03880d935d628608776e138915c23cbe6f780 (patch) | |
tree | 56b06b55da1d627e79a7c7611fb29986870c59ab /src/include | |
parent | 3bc8e303ae07b3d3c9933495b86f6d7ebc0c875c (diff) | |
download | libmm-radio-42e03880d935d628608776e138915c23cbe6f780.tar.gz libmm-radio-42e03880d935d628608776e138915c23cbe6f780.tar.bz2 libmm-radio-42e03880d935d628608776e138915c23cbe6f780.zip |
Added implementation of interruption by resource managersubmit/tizen/20170420.053325accepted/tizen/unified/20170420.154835
1. Add cmd rock during _mm_radio_stop()
[Version] 0.2.25
[Profile] Mobile, Wearable
[Issue Type] Add featuresBrief
Change-Id: I720bbed4681ac7f8c870164d08413d35db3b54ea
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/mm_radio_priv_hal.h | 3 | ||||
-rw-r--r-- | src/include/mm_radio_resource.h | 81 |
2 files changed, 84 insertions, 0 deletions
diff --git a/src/include/mm_radio_priv_hal.h b/src/include/mm_radio_priv_hal.h index 72e2ef3..67bcf82 100644 --- a/src/include/mm_radio_priv_hal.h +++ b/src/include/mm_radio_priv_hal.h @@ -42,6 +42,7 @@ #include <media/sound_manager_internal.h> #endif +#include "mm_radio_resource.h" #include "mm_radio.h" #include "mm_radio_utils.h" #include "radio_hal_interface.h" @@ -193,6 +194,8 @@ typedef struct { mm_radio_hal_interface *hal_inf; + mm_radio_resource_manager resource_manager; + } mm_radio_t; /*=========================================================================================== diff --git a/src/include/mm_radio_resource.h b/src/include/mm_radio_resource.h new file mode 100644 index 0000000..85006ba --- /dev/null +++ b/src/include/mm_radio_resource.h @@ -0,0 +1,81 @@ +/* + * mm_radio_resource.h + * + * Copyright (c) 2017 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: Heechul Jeon <heechul.jeon@samsung.com> + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef __MM_RADIO_RESOURCE_H__ +#define __MM_RADIO_RESOURCE_H__ + +#include <murphy/plugins/resource-native/libmurphy-resource/resource-api.h> +#include <glib.h> + +#ifdef __cplusplus +extern "C" { +#endif + +#define __MMRADIO_RESOURCE_WAIT_TIME 3 + +#define MMRADIO_GET_RESOURCE_LOCK(rm) (&((mm_radio_resource_manager *)rm)->lock) +#define MMRADIO_RESOURCE_LOCK(rm) (g_mutex_lock(MMRADIO_GET_RESOURCE_LOCK(rm))) +#define MMRADIO_RESOURCE_UNLOCK(rm) (g_mutex_unlock(MMRADIO_GET_RESOURCE_LOCK(rm))) + +#define MMRADIO_GET_RESOURCE_COND(rm) (&((mm_radio_resource_manager *)rm)->cond) +#define MMRADIO_RESOURCE_WAIT(rm) g_cond_wait(MMRADIO_GET_RESOURCE_COND(rm), MMRADIO_GET_RESOURCE_LOCK(rm) +#define MMRADIO_RESOURCE_WAIT_UNTIL(rm, end_time) \ + g_cond_wait_until(MMRADIO_GET_RESOURCE_COND(rm), MMRADIO_GET_RESOURCE_LOCK(rm), end_time) +#define MMRADIO_RESOURCE_SIGNAL(rm) g_cond_signal(MMRADIO_GET_RESOURCE_COND(rm)); + + +typedef enum { + MM_RADIO_RESOURCE_TYPE_RADIO, + MM_RADIO_RESOURCE_MAX +} mm_radio_resource_type_e; + +typedef enum { + MM_RADIO_RESOURCE_STATE_NONE, + MM_RADIO_RESOURCE_STATE_INITIALIZED, + MM_RADIO_RESOURCE_STATE_PREPARED, + MM_RADIO_RESOURCE_STATE_ACQUIRED, + MM_RADIO_RESOURCE_STATE_MAX, +} mm_radio_resource_state_e; + +typedef struct { + mrp_mainloop_t *mloop; + mrp_res_context_t *context; + mrp_res_resource_set_t *rset; + mm_radio_resource_state_e state; + GCond cond; + GMutex lock; + void *user_data; + bool is_connected; + bool by_rm_cb; +} mm_radio_resource_manager; + +int mmradio_resource_manager_init(mm_radio_resource_manager *resource_manager, void *user_data); +int mmradio_resource_manager_deinit(mm_radio_resource_manager *resource_manager); +int mmradio_resource_manager_prepare(mm_radio_resource_manager *resource_manager, mm_radio_resource_type_e resource_type); +int mmradio_resource_manager_unprepare(mm_radio_resource_manager *resource_manager); +int mmradio_resource_manager_acquire(mm_radio_resource_manager *resource_manager); +int mmradio_resource_manager_release(mm_radio_resource_manager *resource_manager); + +#ifdef __cplusplus +} +#endif + +#endif /* __MM_RADIO_RESOURCE_H__ */ |