summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGilbok Lee <gilbok.lee@samsung.com>2018-08-24 04:28:21 +0000
committerGilbok Lee <gilbok.lee@samsung.com>2018-08-24 04:28:21 +0000
commitc10f1b656c40594b1c55ce5bd0ab833831b68f40 (patch)
treebfd08ba0d338dcd2dcf1b1d1f3ae3a54a524177a
parentd15d19531cf004eea3b846d50c62c0faf857c9d1 (diff)
downloadlibmm-radio-c10f1b656c40594b1c55ce5bd0ab833831b68f40.tar.gz
libmm-radio-c10f1b656c40594b1c55ce5bd0ab833831b68f40.tar.bz2
libmm-radio-c10f1b656c40594b1c55ce5bd0ab833831b68f40.zip
Revert "Using radio-hal-interface in mm-hal-interface"
This reverts commit d15d19531cf004eea3b846d50c62c0faf857c9d1. Change-Id: I3ef458e8e6cc3713cb33d0c400522eea39a27d9f
-rwxr-xr-xconfigure.ac6
-rwxr-xr-xmm-radio.pc.in2
-rwxr-xr-xpackaging/libmm-radio.spec3
-rwxr-xr-xsrc/Makefile.am7
-rw-r--r--src/include/radio_hal_interface.h61
-rw-r--r--src/include/tizen-radio.h307
-rw-r--r--src/mm_radio_priv_hal.c2
-rw-r--r--src/radio_hal_interface.c317
8 files changed, 690 insertions, 15 deletions
diff --git a/configure.ac b/configure.ac
index 8b9ad7c..ccf3d34 100755
--- a/configure.ac
+++ b/configure.ac
@@ -46,10 +46,6 @@ PKG_CHECK_MODULES(DLOG, dlog)
AC_SUBST(DLOG_CFLAGS)
AC_SUBST(DLOG_LIBS)
-PKG_CHECK_MODULES(RADIO_HAL_INTF, radio-hal-interface)
-AC_SUBST(RADIO_HAL_INTF_CFLAGS)
-AC_SUBST(RADIO_HAL_INTF_LIBS)
-
AC_ARG_ENABLE(emulator, AC_HELP_STRING([--enable-emulator], [using emulator interface]),
[
case "${enableval}" in
@@ -81,7 +77,7 @@ AC_ARG_ENABLE(sound-vstream, AC_HELP_STRING([--enable-sound-vstream], [using sou
AM_CONDITIONAL(ENABLE_SOUND_VSTREAM, test "x$ENABLE_SOUND_VSTREAM" = "xyes")
if test "x$ENABLE_SOUND_VSTREAM" == "xyes"; then
- PKG_CHECK_MODULES(SOUNDMGR, capi-media-sound-manager)
+ PKG_CHECK_MODULES(SOUDNMGR, capi-media-sound-manager)
AC_SUBST(SOUNDMGR_CFLAGS)
AC_SUBST(SOUNDMGR_LIBS)
fi
diff --git a/mm-radio.pc.in b/mm-radio.pc.in
index 5b0af75..5b9f91f 100755
--- a/mm-radio.pc.in
+++ b/mm-radio.pc.in
@@ -5,7 +5,7 @@ includedir = @includedir@
Name : mm-radio
Description : Multimedia Framwork FM Radio Library
-Requires : mm-common
+Requires : mm-common capi-media-sound-manager
Version : @VERSION@
Libs : -L${libdir} -lmmfradio
Cflags : -I${includedir}/mmf
diff --git a/packaging/libmm-radio.spec b/packaging/libmm-radio.spec
index cbfc733..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.43
+Version: 0.2.42
Release: 0
Group: System/Libraries
License: Apache-2.0
@@ -16,7 +16,6 @@ BuildRequires: pkgconfig(gstreamer-1.0)
BuildRequires: pkgconfig(gstreamer-plugins-base-1.0)
%endif
BuildRequires: pkgconfig(mm-resource-manager)
-BuildRequires: pkgconfig(radio-hal-interface)
%description
Description: Multimedia Framework Radio Library
diff --git a/src/Makefile.am b/src/Makefile.am
index f257cf0..9bad76c 100755
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -26,11 +26,8 @@ libmmfradio_la_CFLAGS += $(GST_CFLAGS) \
libmmfradio_la_LIBADD += $(GST_LIBS) \
$(GSTAPP_LIBS)
else
-libmmfradio_la_SOURCES += mm_radio_priv_hal.c
-
-libmmfradio_la_CFLAGS += $(RADIO_HAL_INTF_CFLAGS)
-
-libmmfradio_la_LIBADD += $(RADIO_HAL_INTF_LIBS)
+libmmfradio_la_SOURCES += mm_radio_priv_hal.c \
+ radio_hal_interface.c
endif
if ENABLE_SOUND_VSTREAM
diff --git a/src/include/radio_hal_interface.h b/src/include/radio_hal_interface.h
new file mode 100644
index 0000000..cb4a1d0
--- /dev/null
+++ b/src/include/radio_hal_interface.h
@@ -0,0 +1,61 @@
+/*
+ * radio_hal_interface.h
+ *
+ * Copyright (c) 2000 - 2016 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * 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.
+ *
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include "tizen-radio.h"
+
+typedef enum _seek_direction_type {
+ SEEK_DIRECTION_UP, /**< Seek upward */
+ SEEK_DIRECTION_DOWN /**< Seek downward */
+} seek_direction_type_t;
+
+typedef struct _radio_hal_interface {
+ void *dl_handle;
+ void *rh_handle;
+ radio_interface_t intf;
+} radio_hal_interface;
+
+int radio_hal_interface_init(radio_hal_interface **handle);
+int radio_hal_interface_deinit(radio_hal_interface *handle);
+int radio_hal_open(radio_hal_interface *handle);
+int radio_hal_prepare(radio_hal_interface *handle);
+int radio_hal_unprepare(radio_hal_interface *handle);
+int radio_hal_close(radio_hal_interface *handle);
+int radio_hal_start(radio_hal_interface *handle);
+int radio_hal_stop(radio_hal_interface *handle);
+int radio_hal_seek(radio_hal_interface *handle, seek_direction_type_t direction);
+int radio_hal_get_frequency(radio_hal_interface *handle, uint32_t *frequency);
+int radio_hal_set_frequency(radio_hal_interface *handle, uint32_t frequency);
+int radio_hal_get_signal_strength(radio_hal_interface *handle, int32_t *strength);
+int radio_hal_mute(radio_hal_interface *handle);
+int radio_hal_unmute(radio_hal_interface *handle);
+int radio_hal_set_volume(radio_hal_interface *handle, float volume);
+int radio_hal_get_volume(radio_hal_interface *handle, float *volume);
+int radio_hal_set_media_volume(radio_hal_interface *handle, uint32_t level);
+
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/src/include/tizen-radio.h b/src/include/tizen-radio.h
new file mode 100644
index 0000000..494df04
--- /dev/null
+++ b/src/include/tizen-radio.h
@@ -0,0 +1,307 @@
+/*
+ * tizen-radio.h
+ *
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * 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 __TIZEN_RADIO_HAL_H__
+#define __TIZEN_RADIO_HAL_H__
+
+#include <stdint.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/**
+ * @file tizen-radio.h
+ * @brief This file contains the Tizen radio HAL API, related structures and enumerations.
+ * @since_tizen 3.0
+ */
+
+/**
+ * @addtogroup TIZEN_RADIO_HAL_MODULE
+ * @{
+ */
+
+/**
+ * @brief Enumeration for the radio error.
+ * @since_tizen 3.0
+ */
+typedef enum radio_error {
+ RADIO_ERROR_NONE,
+ RADIO_ERROR_INVALID_PARAMETER,
+ RADIO_ERROR_INVALID_OPERATION,
+ RADIO_ERROR_PERMISSION_DENIED,
+ RADIO_ERROR_NOT_SUPPORTED,
+ RADIO_ERROR_OUT_OF_MEMORY,
+ RADIO_ERROR_DEVICE_NOT_PREPARED,
+ RADIO_ERROR_DEVICE_NOT_OPENED,
+ RADIO_ERROR_DEVICE_NOT_FOUND,
+ RADIO_ERROR_NO_ANTENNA,
+ RADIO_ERROR_INTERNAL,
+ RADIO_ERROR_NOT_IMPLEMENTED,
+ RADIO_ERROR_UNKNOWN
+} radio_error_t;
+
+/**
+ * @brief Enumeration for the radio seek direction.
+ * @since_tizen 3.0
+ */
+typedef enum radio_seek_direction_type {
+ RADIO_SEEK_DIRECTION_UP, /**< Seek upward */
+ RADIO_SEEK_DIRECTION_DOWN /**< Seek downward */
+} radio_seek_direction_type_t;
+
+typedef struct radio_interface {
+ /* create & destroy */
+ radio_error_t (*init)(void **radio_hanle);
+ radio_error_t (*deinit)(void *radio_handle);
+ radio_error_t (*prepare)(void *radio_handle);
+ radio_error_t (*unprepare)(void *radio_handle);
+ radio_error_t (*open)(void *radio_handle);
+ radio_error_t (*close)(void *radio_handle);
+ radio_error_t (*start)(void *radio_handle);
+ radio_error_t (*stop)(void *radio_handle);
+ radio_error_t (*seek)(void *radio_handle, radio_seek_direction_type_t direction);
+ radio_error_t (*get_frequency)(void *radio_handle, uint32_t *frequency);
+ radio_error_t (*set_frequency)(void *radio_handle, uint32_t frequency);
+ radio_error_t (*mute)(void *radio_handle);
+ radio_error_t (*unmute)(void *radio_handle);
+ radio_error_t (*get_signal_strength)(void *radio_handle, int32_t *strength);
+ radio_error_t (*get_volume)(void *radio_handle, float *volume);
+ radio_error_t (*set_volume)(void *radio_handle, float volume);
+ radio_error_t (*set_media_volume)(void *radio_handle, uint32_t level);
+} radio_interface_t;
+
+/**
+ * @brief Initializes new handle of radio HAL.
+ * @since_tizen 3.0
+ * @param[out] radio_handle A newly returned the radio HAL handle
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #RADIO_ERROR_NONE Successful
+ * @retval #RADIO_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #RADIO_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #RADIO_ERROR_INVALID_OPERATION Invalid operation
+ * @see radio_deinit()
+ */
+radio_error_t radio_init(void **radio_handle);
+
+/**
+ * @brief Deinitializes handle of radio HAL.
+ * @since_tizen 3.0
+ * @param[in] radio_handle The radio HAL handle
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #RADIO_ERROR_NONE Successful
+ * @retval #RADIO_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see radio_init()
+ */
+radio_error_t radio_deinit(void *radio_handle);
+
+/**
+ * @brief Prepare the device of radio.
+ * @since_tizen 3.0
+ * @param[in] radio_handle The radio HAL handle
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #RADIO_ERROR_NONE Successful
+ * @retval #RADIO_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #RADIO_ERROR_INVALID_OPERATION Invalid operation
+ * @see radio_unprepare()
+ */
+radio_error_t radio_prepare(void *radio_handle);
+
+/**
+ * @brief Unprepare the device of radio.
+ * @since_tizen 3.0
+ * @param[in] radio_handle The radio HAL handle
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #RADIO_ERROR_NONE Successful
+ * @retval #RADIO_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #RADIO_ERROR_INVALID_OPERATION Invalid operation
+ * @see radio_prepare()
+ */
+radio_error_t radio_unprepare(void *radio_handle);
+
+/**
+ * @brief Opens the device of radio.
+ * @since_tizen 3.0
+ * @param[in] radio_handle The radio HAL handle
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #RADIO_ERROR_NONE Successful
+ * @retval #RADIO_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #RADIO_ERROR_DEVICE_NOT_FOUND Failed to find radio device
+ * @retval #RADIO_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #RADIO_ERROR_PERMISSION_DENIED The access to the resources can not be granted.
+ * @retval #RADIO_ERROR_DEVICE_NOT_PREPARED Not prepared the radio device
+ * @see radio_close()
+ */
+radio_error_t radio_open(void *radio_handle);
+
+/**
+ * @brief Closes the device of radio.
+ * @since_tizen 3.0
+ * @param[in] radio_handle The radio HAL handle
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #RADIO_ERROR_NONE Successful
+ * @retval #RADIO_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #RADIO_ERROR_DEVICE_NOT_OPENED The radio device is not opened.
+ * @retval #RADIO_ERROR_INVALID_OPERATION Invalid operation
+ * @see radio_open()
+ */
+radio_error_t radio_close(void *radio_handle);
+
+/**
+ * @brief Starts the device of radio.
+ * @since_tizen 3.0
+ * @param[in] radio_handle The radio HAL handle
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #RADIO_ERROR_NONE Successful
+ * @retval #RADIO_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #RADIO_ERROR_DEVICE_NOT_OPENED The radio device is not opened.
+ * @see radio_stop()
+ */
+radio_error_t radio_start(void *radio_handle);
+
+/**
+ * @brief Stops the device of radio.
+ * @since_tizen 3.0
+ * @param[in] radio_handle The radio HAL handle
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #RADIO_ERROR_NONE Successful
+ * @retval #RADIO_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #RADIO_ERROR_DEVICE_NOT_OPENED The radio device is not opened.
+ * @see radio_start()
+ */
+radio_error_t radio_stop(void *radio_handle);
+
+/**
+ * @brief Seeks (up or down) the effective frequency of the radio.
+ * @since_tizen 3.0
+ * @param[in] radio_handle The radio HAL handle
+ * @param[in] direction The seek direction type (up or down)
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #RADIO_ERROR_NONE Successful
+ * @retval #RADIO_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #RADIO_ERROR_DEVICE_NOT_OPENED The radio device is not opened
+ * @retval #RADIO_ERROR_INVALID_OPERATION Invalid operation
+ */
+radio_error_t radio_seek(void *radio_handle, radio_seek_direction_type_t direction);
+
+/**
+ * @brief Gets the radio frequency.
+ * @since_tizen 3.0
+ * @param[in] radio_handle The radio HAL handle
+ * @param[out] frequency The current frequency (khz)
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #RADIO_ERROR_NONE Successful
+ * @retval #RADIO_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #RADIO_ERROR_INVALID_OPERATION Invalid operation
+ */
+radio_error_t radio_get_frequency(void *radio_handle, uint32_t *frequency);
+
+/**
+ * @brief Sets the radio frequency.
+ * @since_tizen 3.0
+ * @param[in] radio_handle The radio HAL handle
+ * @param[in] frequency The frequency to set (khz)
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #RADIO_ERROR_NONE Successful
+ * @retval #RADIO_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #RADIO_ERROR_INVALID_OPERATION Invalid operation
+ */
+radio_error_t radio_set_frequency(void *radio_handle, uint32_t frequency);
+
+/**
+ * @brief Sets the radio's mute
+ * @since_tizen 3.0
+ * @param[in] radio_handle The radio HAL handle
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #RADIO_ERROR_NONE Successful
+ * @retval #RADIO_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #RADIO_ERROR_INVALID_OPERATION Invalid operation
+ */
+radio_error_t radio_mute(void *radio_handle);
+
+/**
+ * @brief Unsets the radio's mute
+ * @since_tizen 3.0
+ * @param[in] radio_handle The radio HAL handle
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #RADIO_ERROR_NONE Successful
+ * @retval #RADIO_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #RADIO_ERROR_INVALID_OPERATION Invalid operation
+ */
+radio_error_t radio_unmute(void *radio_handle);
+
+/**
+ * @brief Gets the current signal strength of the radio
+ * @since_tizen 3.0
+ * @param[in] radio_handle The radio HAL handle
+ * @param[out] strength The current signal strength (dBm)
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #RADIO_ERROR_NONE Successful
+ * @retval #RADIO_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #RADIO_ERROR_INVALID_OPERATION Invalid operation
+ */
+radio_error_t radio_get_signal_strength(void *radio_handle, int32_t *strength);
+
+/**
+ * @brief Gets the radio's current volume.
+ * @since_tizen 3.0
+ * @param[in] radio_handle The radio HAL handle
+ * @param[out] volume The current radio volume (0.0 ~ 1.0)
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #RADIO_ERROR_NONE Successful
+ * @retval #RADIO_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #RADIO_ERROR_INVALID_OPERATION Invalid operation
+ */
+radio_error_t radio_get_volume(void *radio_handle, float *volume);
+
+/**
+ * @brief Sets the current radio's volume.
+ * @since_tizen 3.0
+ * @param[in] radio_handle The radio HAL handle
+ * @param[in] volume The radio volume to set (0.0 ~ 1.0)
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #RADIO_ERROR_NONE Successful
+ * @retval #RADIO_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #RADIO_ERROR_INVALID_OPERATION Invalid operation
+ */
+radio_error_t radio_set_volume(void *radio_handle, float volume);
+
+/**
+ * @brief Sets the current media volume level(system media volume).
+ * @since_tizen 3.0
+ * @param[in] radio_handle The radio HAL handle
+ * @param[in] level The media volume level to set
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #RADIO_ERROR_NONE Successful
+ * @retval #RADIO_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #RADIO_ERROR_INVALID_OPERATION Invalid operation
+ */
+radio_error_t radio_set_media_volume(void *radio_handle, uint32_t level);
+
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __TIZEN_RADIO_HAL_H__ */
+
diff --git a/src/mm_radio_priv_hal.c b/src/mm_radio_priv_hal.c
index 739e245..b11bc62 100644
--- a/src/mm_radio_priv_hal.c
+++ b/src/mm_radio_priv_hal.c
@@ -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();
diff --git a/src/radio_hal_interface.c b/src/radio_hal_interface.c
new file mode 100644
index 0000000..b4f683b
--- /dev/null
+++ b/src/radio_hal_interface.c
@@ -0,0 +1,317 @@
+/*
+ * radio_hal_interface.c
+ *
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * 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.
+ *
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+#include <dlfcn.h>
+#include <dlog.h>
+
+#include "radio_hal_interface.h"
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif /* LOG_TAG */
+
+#define LOG_TAG "RADIO_HAL_INTF"
+
+#define LIB_TIZEN_RADIO PATH_LIBDIR"/libtizen-radio.so"
+
+#define RADIO_INTF_CHECK_ARG(x_radio) \
+do { \
+ if (!x_radio) { \
+ LOGE("argument is NULL\n"); \
+ return RADIO_ERROR_INVALID_PARAMETER; \
+ } \
+} while (0)
+
+int radio_hal_interface_init(radio_hal_interface **handle)
+{
+ radio_hal_interface *h = NULL;
+ int ret = RADIO_ERROR_NONE;
+ h = (radio_hal_interface *)malloc(sizeof(radio_hal_interface));
+
+ if (!h) {
+ LOGE("cannot allocate memory for radio_hal interface");
+ return RADIO_ERROR_OUT_OF_MEMORY;
+ }
+
+ h->dl_handle = dlopen(LIB_TIZEN_RADIO, RTLD_NOW);
+
+ if (h->dl_handle) {
+ h->intf.init = dlsym(h->dl_handle, "radio_init");
+ h->intf.deinit = dlsym(h->dl_handle, "radio_deinit");
+ h->intf.prepare = dlsym(h->dl_handle, "radio_prepare");
+ h->intf.unprepare = dlsym(h->dl_handle, "radio_unprepare");
+ h->intf.open = dlsym(h->dl_handle, "radio_open");
+ h->intf.close = dlsym(h->dl_handle, "radio_close");
+ h->intf.start = dlsym(h->dl_handle, "radio_start");
+ h->intf.stop = dlsym(h->dl_handle, "radio_stop");
+ h->intf.seek = dlsym(h->dl_handle, "radio_seek");
+ h->intf.get_frequency = dlsym(h->dl_handle, "radio_get_frequency");
+ h->intf.set_frequency = dlsym(h->dl_handle, "radio_set_frequency");
+ h->intf.mute = dlsym(h->dl_handle, "radio_mute");
+ h->intf.unmute = dlsym(h->dl_handle, "radio_unmute");
+ h->intf.get_signal_strength = dlsym(h->dl_handle, "radio_get_signal_strength");
+ h->intf.get_volume = dlsym(h->dl_handle, "radio_get_volume");
+ h->intf.set_volume = dlsym(h->dl_handle, "radio_set_volume");
+ h->intf.set_media_volume = dlsym(h->dl_handle, "radio_set_media_volume");
+
+ if (h->intf.init == NULL || h->intf.deinit == NULL) {
+ LOGE("could not get mandatory funtion");
+ goto FAIL;
+ }
+
+ ret = h->intf.init(&h->rh_handle);
+ if (ret != RADIO_ERROR_NONE) {
+ LOGE("radio_hal init failed %d", ret);
+ goto FAIL;
+ }
+
+ } else {
+ LOGE("open radio hal_interface failed : %s", dlerror());
+ ret = RADIO_ERROR_INTERNAL;
+ goto FAIL;
+ }
+
+ *handle = h;
+
+ LOGD("open radio_hal interface");
+
+ return ret;
+FAIL:
+ if (h) {
+ if (h->dl_handle)
+ dlclose(h->dl_handle);
+ free(h);
+ }
+
+ return ret;
+}
+
+int radio_hal_interface_deinit(radio_hal_interface *handle)
+{
+ int ret = RADIO_ERROR_NONE;
+ RADIO_INTF_CHECK_ARG(handle);
+
+ if (handle->dl_handle) {
+ ret = handle->intf.deinit(handle->rh_handle);
+ if (ret != RADIO_ERROR_NONE)
+ return ret;
+
+ handle->rh_handle = NULL;
+
+ LOGD("close radio_hal interface");
+ dlclose(handle->dl_handle);
+ handle->dl_handle = NULL;
+ }
+
+ free(handle);
+ handle = NULL;
+
+ return ret;
+}
+
+int radio_hal_open(radio_hal_interface *handle)
+{
+ RADIO_INTF_CHECK_ARG(handle);
+
+ if (!handle->intf.open) {
+ LOGW("radio_hal open is NULL");
+ return RADIO_ERROR_NOT_IMPLEMENTED;
+ }
+
+ return handle->intf.open(handle->rh_handle);
+}
+
+int radio_hal_prepare(radio_hal_interface *handle)
+{
+ RADIO_INTF_CHECK_ARG(handle);
+
+ if (!handle->intf.prepare) {
+ LOGW("radio_hal prepare is NULL");
+ return RADIO_ERROR_NOT_IMPLEMENTED;
+ }
+
+ return handle->intf.prepare(handle->rh_handle);
+}
+
+int radio_hal_unprepare(radio_hal_interface *handle)
+{
+ RADIO_INTF_CHECK_ARG(handle);
+
+ if (!handle->intf.unprepare) {
+ LOGW("radio_hal unprepare is NULL");
+ return RADIO_ERROR_NOT_IMPLEMENTED;
+ }
+
+ return handle->intf.unprepare(handle->rh_handle);
+}
+
+
+int radio_hal_close(radio_hal_interface *handle)
+{
+ RADIO_INTF_CHECK_ARG(handle);
+
+ if (!handle->intf.close) {
+ LOGW("radio_hal close is NULL");
+ return RADIO_ERROR_NOT_IMPLEMENTED;
+ }
+
+ return handle->intf.close(handle->rh_handle);
+}
+
+int radio_hal_start(radio_hal_interface *handle)
+{
+ RADIO_INTF_CHECK_ARG(handle);
+
+ if (!handle->intf.start) {
+ LOGW("radio_hal start is NULL");
+ return RADIO_ERROR_NOT_IMPLEMENTED;
+ }
+
+ return handle->intf.start(handle->rh_handle);
+}
+
+int radio_hal_stop(radio_hal_interface *handle)
+{
+ RADIO_INTF_CHECK_ARG(handle);
+
+ if (!handle->intf.stop) {
+ LOGW("radio_hal stop is NULL");
+ return RADIO_ERROR_NOT_IMPLEMENTED;
+ }
+
+ return handle->intf.stop(handle->rh_handle);
+}
+
+
+int radio_hal_seek(radio_hal_interface *handle, seek_direction_type_t direction)
+{
+ RADIO_INTF_CHECK_ARG(handle);
+
+ if (!handle->intf.seek) {
+ LOGW("radio_hal seek is NULL");
+ return RADIO_ERROR_NOT_IMPLEMENTED;
+ }
+
+ return handle->intf.seek(handle->rh_handle, (radio_seek_direction_type_t)direction);
+}
+
+int radio_hal_get_frequency(radio_hal_interface *handle, uint32_t *frequency)
+{
+ RADIO_INTF_CHECK_ARG(handle);
+
+ if (!handle->intf.get_frequency) {
+ LOGW("radio_hal get_frequency is NULL");
+ return RADIO_ERROR_NOT_IMPLEMENTED;
+ }
+
+ return handle->intf.get_frequency(handle->rh_handle, frequency);
+}
+
+int radio_hal_set_frequency(radio_hal_interface *handle, uint32_t frequency)
+{
+ RADIO_INTF_CHECK_ARG(handle);
+
+ if (!handle->intf.set_frequency) {
+ LOGW("radio_hal set_frequency is NULL");
+ return RADIO_ERROR_NOT_IMPLEMENTED;
+ }
+
+ return handle->intf.set_frequency(handle->rh_handle, frequency);
+}
+
+int radio_hal_get_signal_strength(radio_hal_interface *handle, int32_t *strength)
+{
+ RADIO_INTF_CHECK_ARG(handle);
+
+ if (!handle->intf.get_signal_strength) {
+ LOGW("radio_hal get_signal_strength is NULL");
+ return RADIO_ERROR_NOT_IMPLEMENTED;
+ }
+
+ return handle->intf.get_signal_strength(handle->rh_handle, strength);
+}
+
+int radio_hal_mute(radio_hal_interface *handle)
+{
+ RADIO_INTF_CHECK_ARG(handle);
+
+ if (!handle->intf.mute) {
+ LOGW("radio_hal mute is NULL");
+ return RADIO_ERROR_NOT_IMPLEMENTED;
+ }
+
+ return handle->intf.mute(handle->rh_handle);
+}
+
+int radio_hal_unmute(radio_hal_interface *handle)
+{
+ RADIO_INTF_CHECK_ARG(handle);
+
+ if (!handle->intf.unmute) {
+ LOGW("radio_hal unmute is NULL");
+ return RADIO_ERROR_NOT_IMPLEMENTED;
+ }
+
+ return handle->intf.unmute(handle->rh_handle);
+}
+
+int radio_hal_set_volume(radio_hal_interface *handle, float volume)
+{
+ RADIO_INTF_CHECK_ARG(handle);
+
+ if (!handle->intf.set_volume) {
+ LOGW("radio_hal set_volume is NULL");
+ return RADIO_ERROR_NOT_IMPLEMENTED;
+ }
+
+ return handle->intf.set_volume(handle->rh_handle, volume);
+}
+
+int radio_hal_get_volume(radio_hal_interface *handle, float *volume)
+{
+ RADIO_INTF_CHECK_ARG(handle);
+
+ if (!handle->intf.get_volume) {
+ LOGW("radio_hal get_volume is NULL");
+ return RADIO_ERROR_NOT_IMPLEMENTED;
+ }
+
+ return handle->intf.get_volume(handle->rh_handle, volume);
+}
+
+int radio_hal_set_media_volume(radio_hal_interface *handle, uint32_t level)
+{
+ RADIO_INTF_CHECK_ARG(handle);
+
+ if (!handle->intf.set_media_volume) {
+ LOGW("radio_hal set_media_volume is NULL");
+ return RADIO_ERROR_NOT_IMPLEMENTED;
+ }
+
+ return handle->intf.set_media_volume(handle->rh_handle, level);
+}
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+