Replace HAL interface 61/251561/6 accepted/tizen/6.5/unified/20211028.114820 accepted/tizen/unified/20210219.040844 submit/tizen/20210218.054309 submit/tizen_6.5/20211028.162401 tizen_6.5.m2_release
authorGilbok Lee <gilbok.lee@samsung.com>
Wed, 17 Feb 2021 06:48:24 +0000 (15:48 +0900)
committerGilbok Lee <gilbok.lee@samsung.com>
Wed, 17 Feb 2021 07:18:18 +0000 (16:18 +0900)
[Version] 0.2.49
[Issue Type] Refactoring

Change-Id: I3423f75d21b58424e410c468c643d755f0e2881e

configure.ac
packaging/libmm-radio.spec
src/Makefile.am
src/include/mm_radio_priv_emul.h [moved from src/include/mm_radio_priv.h with 94% similarity]
src/include/mm_radio_priv_hal.h
src/include/radio_hal_interface.h [deleted file]
src/include/tizen-radio.h [deleted file]
src/mm_radio.c
src/mm_radio_priv_emulator.c
src/mm_radio_priv_hal.c
src/radio_hal_interface.c [deleted file]

index a581fef..7a792b3 100755 (executable)
@@ -71,6 +71,10 @@ if test "x$ENABLE_EMULATOR" == "xyes"; then
   AC_SUBST(GSTAPP_LIBS)
 fi
 
+PKG_CHECK_MODULES(HAL_API_RADIO, hal-api-radio)
+AC_SUBST(HAL_API_RADIO_CFLAGS)
+AC_SUBST(HAL_API_RADIO_LIBS)
+
 AC_ARG_ENABLE(tests, AC_HELP_STRING([--enable-tests], [unittest build]),
 [case "${enableval}" in
   yes) IS_TESTS=yes ;;
index cdc9884..de31e23 100644 (file)
@@ -1,6 +1,6 @@
 Name:       libmm-radio
 Summary:    Multimedia Framework Radio Library
-Version:    0.2.48
+Version:    0.2.49
 Release:    0
 Group:      System/Libraries
 License:    Apache-2.0
@@ -17,6 +17,7 @@ BuildRequires:  pkgconfig(mm-resource-manager)
 %if 0%{?gtests:1}
 BuildRequires:  pkgconfig(gmock)
 %endif
+BuildRequires:  pkgconfig(hal-api-radio)
 
 %description
 Description: Multimedia Framework Radio Library
@@ -42,6 +43,7 @@ export CFLAGS+=" %{optflags} -Wall"
 export CFLAGS+=" -DTIZEN_FEATURE_RADIO_HAL "
 export CFLAGS+=" -DPATH_LIBDIR=\\\"%{_libdir}\\\""
 %endif
+export LDFLAGS+=" -Wl,--as-needed -Wl,--rpath=%{_libdir}/hal"
 
 %configure \
 %ifnarch %{arm}
index c54ffad..026133f 100755 (executable)
@@ -28,6 +28,9 @@ libmmfradio_la_CFLAGS += $(GST_CFLAGS) \
 libmmfradio_la_LIBADD += $(GST_LIBS)  \
                         $(GSTAPP_LIBS)
 else
-libmmfradio_la_SOURCES += mm_radio_priv_hal.c \
-                         radio_hal_interface.c
+libmmfradio_la_SOURCES += mm_radio_priv_hal.c
+
+libmmfradio_la_CFLAGS += $(HAL_API_RADIO_CFLAGS)
+
+libmmfradio_la_LIBADD += $(HAL_API_RADIO_LIBS)
 endif
similarity index 94%
rename from src/include/mm_radio_priv.h
rename to src/include/mm_radio_priv_emul.h
index 1c88fe2..75bf621 100644 (file)
@@ -161,18 +161,15 @@ typedef enum {
 /*---------------------------------------------------------------------------
     GLOBAL DATA TYPE DEFINITIONS:
 ---------------------------------------------------------------------------*/
-#define USE_GST_PIPELINE
 
-#ifdef USE_GST_PIPELINE
 typedef struct _mm_radio_gstreamer_s {
        GMainLoop *loop;
        GstElement *pipeline;
        GstElement *audiosrc;
-       GstElement *queue2;
+       GstElement *converter;
+       GstElement *volume;
        GstElement *audiosink;
-       GstBuffer *output_buffer;
 } mm_radio_gstreamer_s;
-#endif
 
 typedef struct {
        /* radio state */
@@ -186,35 +183,24 @@ typedef struct {
        pthread_mutex_t cmd_lock;
 
        /* radio attributes */
-       MMHandleTypeattrs;
+       MMHandleType *attrs;
 
        MMRadioThread_t thread[MM_RADIO_THREAD_NUM];
 
        /* message callback */
        GAsyncQueue *msg_queue;
        MMMessageCallback msg_cb;
-       voidmsg_cb_param;
+       void *msg_cb_param;
 
        /* radio device fd */
        int radio_fd;
 
-       /* device control */
-       struct v4l2_capability vc;
-       struct v4l2_tuner vt;
-       struct v4l2_control vctrl;
-       struct v4l2_frequency vf;
-
-       /* hw debug */
-       struct v4l2_dbg_register reg;
-
        /* seek */
        int prev_seek_freq;
        MMRadioSeekDirectionType seek_direction;
 
        int freq;
-#ifdef USE_GST_PIPELINE
-       mm_radio_gstreamer_s* pGstreamer_s;
-#endif
+       mm_radio_gstreamer_s *pipeline;
        mm_resource_manager_h resource_manager;
        mm_resource_manager_res_h radio_resource;
        int interrupted_by_resource_conflict;
@@ -222,7 +208,7 @@ typedef struct {
        float local_volume;
 
        /* region settings */
-       MMRadioRegion_t region_setting;
+       MMRadioRegion_t region_setting;
 } mm_radio_t;
 
 /*===========================================================================================
@@ -244,12 +230,10 @@ int _mmradio_seek(mm_radio_t *radio, MMRadioSeekDirectionType direction);
 int _mmradio_start_scan(mm_radio_t *radio);
 int _mmradio_stop_scan(mm_radio_t *radio);
 int _mm_radio_get_signal_strength(mm_radio_t *radio, int *strength);
-#ifdef USE_GST_PIPELINE
 int _mmradio_realize_pipeline(mm_radio_t *radio);
 int _mmradio_start_pipeline(mm_radio_t *radio);
 int _mmradio_stop_pipeline(mm_radio_t *radio);
 int _mmradio_destroy_pipeline(mm_radio_t *radio);
-#endif
 int _mmradio_apply_region(mm_radio_t *radio, MMRadioRegionType region, bool update);
 int _mmradio_get_region_type(mm_radio_t *radio, MMRadioRegionType *type);
 int _mmradio_get_region_frequency_range(mm_radio_t *radio, unsigned int *min_freq, unsigned int *max_freq);
index a629ad7..6221545 100644 (file)
@@ -38,7 +38,6 @@
 
 #include "mm_radio.h"
 #include "mm_radio_utils.h"
-#include "radio_hal_interface.h"
 #include <linux/videodev2.h>
 
 #include <glib.h>
@@ -207,7 +206,7 @@ typedef struct {
        /* region settings */
        MMRadioRegion_t region_setting;
 
-       radio_hal_interface *hal_inf;
+       void *hal_radio;
 
        mm_resource_manager_h resource_manager;
        mm_resource_manager_res_h radio_resource;
diff --git a/src/include/radio_hal_interface.h b/src/include/radio_hal_interface.h
deleted file mode 100644 (file)
index cb4a1d0..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * 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
deleted file mode 100644 (file)
index 494df04..0000000
+++ /dev/null
@@ -1,307 +0,0 @@
-/*
- * 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__ */
-
index b092fd6..419a616 100644 (file)
@@ -31,7 +31,7 @@
 #ifdef TIZEN_FEATURE_RADIO_HAL
 #include "mm_radio_priv_hal.h"
 #else
-#include "mm_radio_priv.h"
+#include "mm_radio_priv_emul.h"
 #endif
 #include "mm_radio_utils.h"
 
index bbd7845..62dc09b 100644 (file)
@@ -36,7 +36,7 @@
 #include <mm_message.h>
 #include <time.h>
 
-#include "mm_radio_priv.h"
+#include "mm_radio_priv_emul.h"
 
 /*===========================================================================================
   LOCAL DEFINITIONS AND DECLARATIONS FOR MODULE
@@ -305,13 +305,13 @@ int _mmradio_realize(mm_radio_t *radio)
        /*      goto error; */
 
        MMRADIO_SET_STATE(radio, MM_RADIO_STATE_READY);
-#ifdef USE_GST_PIPELINE
+
        ret = _mmradio_realize_pipeline(radio);
        if (ret) {
                MMRADIO_LOG_ERROR("failed to realize pipeline");
                return ret;
        }
-#endif
+
        MMRADIO_LOG_FLEAVE();
 
        return MM_ERROR_NONE;
@@ -335,13 +335,11 @@ int _mmradio_unrealize(mm_radio_t * radio)
 
        MMRADIO_SET_STATE(radio, MM_RADIO_STATE_NULL);
 
-#ifdef USE_GST_PIPELINE
        ret = _mmradio_destroy_pipeline(radio);
        if (ret) {
                MMRADIO_LOG_ERROR("failed to destroy pipeline");
                return ret;
        }
-#endif
 
        MMRADIO_LOG_FLEAVE();
 
@@ -399,13 +397,12 @@ int _mmradio_set_frequency(mm_radio_t * radio, int freq)
 
        radio->freq = freq;
 
-#ifdef USE_GST_PIPELINE
-       if (radio->pGstreamer_s) {
+       if (radio->pipeline) {
                int val = 0;
                val = __mmradio_get_wave_num(radio);
-               g_object_set(radio->pGstreamer_s->audiosrc, "wave", val, NULL);
+               g_object_set(radio->pipeline->audiosrc, "wave", val, NULL);
        }
-#endif
+
        MMRADIO_LOG_FLEAVE();
 
        return MM_ERROR_NONE;
@@ -447,12 +444,11 @@ int _mmradio_mute(mm_radio_t * radio)
        if (radio->radio_fd < 0)
                return MM_ERROR_RADIO_NOT_INITIALIZED;
 
-#ifdef USE_GST_PIPELINE
-       if (radio->pGstreamer_s) {
-               g_object_set(radio->pGstreamer_s->audiosink, "mute", 1, NULL);
+       if (radio->pipeline && radio->pipeline->volume) {
+               g_object_set(radio->pipeline->volume, "mute", 1, NULL);
                MMRADIO_LOG_DEBUG("g_object set mute");
        }
-#endif
+
        MMRADIO_LOG_FLEAVE();
 
        return MM_ERROR_NONE;
@@ -467,12 +463,10 @@ int _mmradio_unmute(mm_radio_t * radio)
        MMRADIO_CHECK_STATE_RETURN_IF_FAIL(radio, MMRADIO_COMMAND_UNMUTE);
        MMRADIO_CHECK_DEVICE_STATE(radio);
 
-#ifdef USE_GST_PIPELINE
-       if (radio->pGstreamer_s) {
-               g_object_set(radio->pGstreamer_s->audiosink, "mute", 0, NULL);
+       if (radio->pipeline && radio->pipeline->volume) {
+               g_object_set(radio->pipeline->volume, "mute", 0, NULL);
                MMRADIO_LOG_DEBUG("g_object set unmute");
        }
-#endif
 
        MMRADIO_LOG_FLEAVE();
 
@@ -604,17 +598,11 @@ int _mmradio_start(mm_radio_t * radio)
 
        _mmradio_set_volume(radio, radio->local_volume);
 
-       /* unmute */
-       /*  if( _mmradio_unmute(radio) != MM_ERROR_NONE) */
-       /*      return MM_ERROR_RADIO_NOT_INITIALIZED; */
-
-#ifdef USE_GST_PIPELINE
        ret = _mmradio_start_pipeline(radio);
        if (ret) {
                MMRADIO_LOG_ERROR("failed to start pipeline");
                return ret;
        }
-#endif
 
        MMRADIO_SET_STATE(radio, MM_RADIO_STATE_PLAYING);
 
@@ -652,52 +640,54 @@ int _mmradio_stop(mm_radio_t * radio)
 
        MMRADIO_SET_STATE(radio, MM_RADIO_STATE_READY);
 
-#ifdef USE_GST_PIPELINE
        ret = _mmradio_stop_pipeline(radio);
        if (ret) {
                MMRADIO_LOG_ERROR("failed to stop pipeline");
                return ret;
        }
-#endif
 
        MMRADIO_LOG_FLEAVE();
 
        return ret;
 }
 
-#ifdef USE_GST_PIPELINE
 int _mmradio_realize_pipeline(mm_radio_t * radio)
 {
        int ret = MM_ERROR_NONE;
        int val = 0;
        MMRADIO_LOG_FENTER();
        gst_init(NULL, NULL);
-       radio->pGstreamer_s = g_new0(mm_radio_gstreamer_s, 1);
+       radio->pipeline = g_new0(mm_radio_gstreamer_s, 1);
 
-       radio->pGstreamer_s->pipeline = gst_pipeline_new("fmradio");
+       radio->pipeline->pipeline = gst_pipeline_new("fmradio");
 
-       radio->pGstreamer_s->audiosrc = gst_element_factory_make("audiotestsrc", "fm audio src");
-       radio->pGstreamer_s->queue2 = gst_element_factory_make("queue2", "queue2");
-       radio->pGstreamer_s->audiosink = gst_element_factory_make("pulsesink", "audio sink");
+       radio->pipeline->audiosrc = gst_element_factory_make("audiotestsrc", "fm audio src");
+       radio->pipeline->converter = gst_element_factory_make("audioconvert", "audioconvert");
+       radio->pipeline->audiosink = gst_element_factory_make("pulsesink", "audio sink");
+       radio->pipeline->volume = gst_element_factory_make("volume", "audiovolume");
+       radio->pipeline->audiosink = gst_element_factory_make("pulsesink", "audio sink");
 
        val = __mmradio_get_wave_num(radio);
-       g_object_set(radio->pGstreamer_s->audiosrc, "wave", val, "volume", 0.8, NULL);
+       g_object_set(radio->pipeline->audiosrc, "wave", val, "volume", 0.8, NULL);
 
-       if (!radio->pGstreamer_s->pipeline || !radio->pGstreamer_s->audiosrc || !radio->pGstreamer_s->queue2 || !radio->pGstreamer_s->audiosink) {
+       if (!radio->pipeline->pipeline || !radio->pipeline->audiosrc
+               || !radio->pipeline->converter || !radio->pipeline->volume
+               || !radio->pipeline->audiosink) {
                MMRADIO_LOG_DEBUG("One element could not be created. Exiting.");
                return MM_ERROR_RADIO_NOT_INITIALIZED;
        }
 
-       gst_bin_add_many(GST_BIN(radio->pGstreamer_s->pipeline),
-                                       radio->pGstreamer_s->audiosrc,
-                                       radio->pGstreamer_s->queue2,
-                                       radio->pGstreamer_s->audiosink,
+       gst_bin_add_many(GST_BIN(radio->pipeline->pipeline),
+                                       radio->pipeline->audiosrc,
+                                       radio->pipeline->converter,
+                                       radio->pipeline->volume,
+                                       radio->pipeline->audiosink,
                                        NULL);
-       if (!gst_element_link_many(
-               radio->pGstreamer_s->audiosrc,
-               radio->pGstreamer_s->queue2,
-               radio->pGstreamer_s->audiosink,
-               NULL)) {
+       if (!gst_element_link_many(radio->pipeline->audiosrc,
+                                                       radio->pipeline->converter,
+                                                       radio->pipeline->volume,
+                                                       radio->pipeline->audiosink,
+                                                       NULL)) {
                MMRADIO_LOG_DEBUG("failed to element link (src - queue - sink)");
                return MM_ERROR_RADIO_NOT_INITIALIZED;
        }
@@ -712,12 +702,12 @@ int _mmradio_start_pipeline(mm_radio_t * radio)
 
        MMRADIO_LOG_FENTER();
 
-       if (gst_element_set_state(radio->pGstreamer_s->pipeline, GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE) {
+       if (gst_element_set_state(radio->pipeline->pipeline, GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE) {
                MMRADIO_LOG_ERROR("failed to change pipeline state");
                return MM_ERROR_RADIO_INVALID_STATE;
        }
 
-       ret_state = gst_element_get_state(radio->pGstreamer_s->pipeline, NULL, NULL, RADIO_GST_STATE_CHANGE_TIMEOUT);
+       ret_state = gst_element_get_state(radio->pipeline->pipeline, NULL, NULL, RADIO_GST_STATE_CHANGE_TIMEOUT);
        if (ret_state == GST_STATE_CHANGE_FAILURE) {
                MMRADIO_LOG_ERROR("GST_STATE_CHANGE_FAILURE");
                return MM_ERROR_RADIO_INVALID_STATE;
@@ -735,12 +725,12 @@ int _mmradio_stop_pipeline(mm_radio_t * radio)
        GstStateChangeReturn ret_state;
 
        MMRADIO_LOG_FENTER();
-       if (gst_element_set_state(radio->pGstreamer_s->pipeline, GST_STATE_READY) == GST_STATE_CHANGE_FAILURE) {
+       if (gst_element_set_state(radio->pipeline->pipeline, GST_STATE_READY) == GST_STATE_CHANGE_FAILURE) {
                MMRADIO_LOG_ERROR("Fail to change pipeline state");
                return MM_ERROR_RADIO_INVALID_STATE;
        }
 
-       ret_state = gst_element_get_state(radio->pGstreamer_s->pipeline, NULL, NULL, RADIO_GST_STATE_CHANGE_TIMEOUT);
+       ret_state = gst_element_get_state(radio->pipeline->pipeline, NULL, NULL, RADIO_GST_STATE_CHANGE_TIMEOUT);
        if (ret_state == GST_STATE_CHANGE_FAILURE) {
                MMRADIO_LOG_ERROR("GST_STATE_CHANGE_FAILURE");
                return MM_ERROR_RADIO_INVALID_STATE;
@@ -757,31 +747,30 @@ int _mmradio_destroy_pipeline(mm_radio_t * radio)
        GstStateChangeReturn ret_state;
        MMRADIO_LOG_FENTER();
 
-       MMRADIO_CHECK_ARG(radio->pGstreamer_s);
+       MMRADIO_CHECK_ARG(radio->pipeline);
 
-       if (gst_element_set_state(radio->pGstreamer_s->pipeline, GST_STATE_NULL) == GST_STATE_CHANGE_FAILURE) {
+       if (gst_element_set_state(radio->pipeline->pipeline, GST_STATE_NULL) == GST_STATE_CHANGE_FAILURE) {
                MMRADIO_LOG_DEBUG("failed to change pipeline state");
-               gst_object_unref(radio->pGstreamer_s->pipeline);
-               MMRADIO_GFREEIF(radio->pGstreamer_s);
+               gst_object_unref(radio->pipeline->pipeline);
+               MMRADIO_GFREEIF(radio->pipeline);
                return MM_ERROR_RADIO_INVALID_STATE;
        }
 
-       ret_state = gst_element_get_state(radio->pGstreamer_s->pipeline, NULL, NULL, RADIO_GST_STATE_CHANGE_TIMEOUT);
+       ret_state = gst_element_get_state(radio->pipeline->pipeline, NULL, NULL, RADIO_GST_STATE_CHANGE_TIMEOUT);
        if (ret_state == GST_STATE_CHANGE_FAILURE) {
                MMRADIO_LOG_DEBUG("GST_STATE_CHANGE_FAILURE");
-               gst_object_unref(radio->pGstreamer_s->pipeline);
-               MMRADIO_GFREEIF(radio->pGstreamer_s);
+               gst_object_unref(radio->pipeline->pipeline);
+               MMRADIO_GFREEIF(radio->pipeline);
                return MM_ERROR_RADIO_INVALID_STATE;
        } else {
                MMRADIO_LOG_DEBUG("GST_STATE_NULL ret_state = %d (GST_STATE_CHANGE_SUCCESS)", ret_state);
        }
 
-       gst_object_unref(radio->pGstreamer_s->pipeline);
-       MMRADIO_GFREEIF(radio->pGstreamer_s);
+       gst_object_unref(radio->pipeline->pipeline);
+       MMRADIO_GFREEIF(radio->pipeline);
        MMRADIO_LOG_FLEAVE();
        return ret;
 }
-#endif
 
 int _mmradio_seek(mm_radio_t * radio, MMRadioSeekDirectionType direction)
 {
@@ -1054,8 +1043,8 @@ void __mmradio_seek_thread(mm_radio_t * radio)
                }
 
                emulatoridx = 0;
+               freq = 0;
                MMRADIO_LOG_DEBUG("start radio->freq: %d", radio->freq);
-               freq = radio->freq;
 
                if (radio->seek_direction == MM_RADIO_SEEK_UP) {
                        for (i = 0; i < EMULATOR_FREQ_MAX; i++) {
@@ -1065,19 +1054,19 @@ void __mmradio_seek_thread(mm_radio_t * radio)
                                        break;
                                }
                        }
-                       if (freq == radio->freq) {
+                       if (!freq) {
                                freq = MMRadioEmulatorFreq[0];
                                emulatoridx = 0;
                        }
                } else {
-                       for (i = EMULATOR_FREQ_MAX - 1; i < 0; i--) {
+                       for (i = EMULATOR_FREQ_MAX - 1; i >= 0; i--) {
                                if (radio->freq > MMRadioEmulatorFreq[i]) {
                                        freq = MMRadioEmulatorFreq[i];
                                        emulatoridx = i;
                                        break;
                                }
                        }
-                       if (freq == radio->freq) {
+                       if (!freq) {
                                freq = MMRadioEmulatorFreq[EMULATOR_FREQ_MAX - 1];
                                emulatoridx = EMULATOR_FREQ_MAX - 1;
                        }
@@ -1370,31 +1359,20 @@ static int __mmradio_get_wave_num(mm_radio_t * radio)
 {
        int val = 0;
        MMRADIO_LOG_FENTER();
-       switch (radio->freq) {
-       case 89100:
-               val = 1;
-               break;
 
-       case 89900:
+       if (radio->freq <= MMRadioEmulatorFreq[0])
+               val = 1;
+       else if (radio->freq <= MMRadioEmulatorFreq[1])
                val = 2;
-               break;
-
-       case 91900:
+       else if (radio->freq <= MMRadioEmulatorFreq[2])
                val = 5;
-               break;
-
-       case 99900:
-               val = 8;
-               break;
-
-       case 107700:
+       else if (radio->freq <= MMRadioEmulatorFreq[3])
+               val = 7;
+       else if (radio->freq <= MMRadioEmulatorFreq[4])
                val = 9;
-               break;
+       else
+               val = 11;
 
-       default:
-               val = 9;
-               break;
-       }
        MMRADIO_LOG_DEBUG("freq: %d, val : %d", radio->freq, val);
        MMRADIO_LOG_FLEAVE();
        return val;
@@ -1452,12 +1430,11 @@ int _mmradio_set_volume(mm_radio_t *radio, float volume)
 
        radio->local_volume = volume;
 
-#ifdef USE_GST_PIPELINE
-       if (radio->pGstreamer_s && radio->pGstreamer_s->audiosink) {
-               g_object_set(radio->pGstreamer_s->audiosink, "volume", volume, NULL);
+       if (radio->pipeline && radio->pipeline->volume) {
+               g_object_set(radio->pipeline->volume, "volume", volume, NULL);
                MMRADIO_LOG_DEBUG("g_object set volume");
        }
-#endif
+
        MMRADIO_LOG_FLEAVE();
 
        return MM_ERROR_NONE;
index f59e1b7..c65f50e 100644 (file)
@@ -36,6 +36,7 @@
 #include <mm_error.h>
 #include <mm_message.h>
 
+#include <hal/hal-radio.h>
 #include "mm_radio_priv_hal.h"
 
 /*===========================================================================================
@@ -69,7 +70,6 @@
 
 #define RADIO_DEFAULT_REGION   MM_RADIO_REGION_GROUP_USA
 #define READ_MAX_BUFFER_SIZE   1024
-#define DEFAULT_MAX_MEDIA_VOLUME       15
 /*---------------------------------------------------------------------------
     LOCAL CONSTANT DEFINITIONS:
 ---------------------------------------------------------------------------*/
@@ -131,6 +131,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 int __mmradio_prepare_radio_device(mm_radio_t *radio);
 static void __mmradio_close_radio_device(mm_radio_t *radio);
 typedef void (*thread_function)(mm_radio_t *);
 thread_function __mmradio_thread_function[] = {
@@ -147,43 +148,43 @@ static int __convert_error_code(int code, char *func_name)
 
        switch (code) {
 
-       case RADIO_ERROR_NONE:
+       case HAL_RADIO_ERROR_NONE:
                ret = MM_ERROR_NONE;
                msg = "MM_ERROR_NONE";
                break;
-       case RADIO_ERROR_INVALID_PARAMETER:
+       case HAL_RADIO_ERROR_INVALID_PARAMETER:
                ret = MM_ERROR_INVALID_ARGUMENT;
                msg = "MM_ERROR_INVALID_ARGUMENT";
                break;
-       case RADIO_ERROR_PERMISSION_DENIED:
+       case HAL_RADIO_ERROR_PERMISSION_DENIED:
                ret = MM_ERROR_RADIO_PERMISSION_DENIED;
                msg = "MM_ERROR_RADIO_PERMISSION_DENIED";
                break;
-       case RADIO_ERROR_NOT_SUPPORTED:
-       case RADIO_ERROR_NOT_IMPLEMENTED:
+       case HAL_RADIO_ERROR_NOT_SUPPORTED:
+       case HAL_RADIO_ERROR_NOT_IMPLEMENTED:
                ret = MM_ERROR_NOT_IMPLEMENTED;
                msg = "MM_ERROR_NOT_IMPLEMENTED";
                break;
-       case RADIO_ERROR_OUT_OF_MEMORY:
+       case HAL_RADIO_ERROR_OUT_OF_MEMORY:
                ret = MM_ERROR_OUT_OF_MEMORY;
                msg = "MM_ERROR_OUT_OF_MEMORY";
                break;
-       case RADIO_ERROR_DEVICE_NOT_PREPARED:
-       case RADIO_ERROR_DEVICE_NOT_OPENED:
+       case HAL_RADIO_ERROR_DEVICE_NOT_PREPARED:
+       case HAL_RADIO_ERROR_DEVICE_NOT_OPENED:
                ret = MM_ERROR_RADIO_DEVICE_NOT_OPENED;
                msg = "MM_ERROR_RADIO_DEVICE_NOT_OPENED";
                break;
-       case RADIO_ERROR_DEVICE_NOT_FOUND:
+       case HAL_RADIO_ERROR_DEVICE_NOT_FOUND:
                ret = MM_ERROR_RADIO_DEVICE_NOT_FOUND;
                msg = "MM_ERROR_RADIO_DEVICE_NOT_FOUND";
                break;
-       case RADIO_ERROR_NO_ANTENNA:
+       case HAL_RADIO_ERROR_NO_ANTENNA:
                ret = MM_ERROR_RADIO_NO_ANTENNA;
                msg = "MM_ERROR_RADIO_NO_ANTENNA";
                break;
-       case RADIO_ERROR_INVALID_OPERATION:
-       case RADIO_ERROR_UNKNOWN:
-       case RADIO_ERROR_INTERNAL:
+       case HAL_RADIO_ERROR_INVALID_OPERATION:
+       case HAL_RADIO_ERROR_UNKNOWN:
+       case HAL_RADIO_ERROR_INTERNAL:
        default:
                ret = MM_ERROR_RADIO_INTERNAL;
                msg = "MM_ERROR_RADIO_INTERNAL";
@@ -275,9 +276,17 @@ int _mmradio_create_radio(mm_radio_t *radio)
                goto ERROR_RESOURCE;
        }
 
-       ret = radio_hal_interface_init(&(radio->hal_inf));
+       ret = hal_radio_get_backend(&(radio->hal_radio));
        if (ret) {
-               MMRADIO_LOG_ERROR("failed to init mmradio hal interface");
+               MMRADIO_LOG_ERROR("failed to get hal radio backend");
+               ret = __convert_error_code(ret, (char *)__FUNCTION__);
+               goto ERROR_HAL_INIT;
+       }
+
+       ret = hal_radio_init(radio->hal_radio);
+       if (ret) {
+               MMRADIO_LOG_ERROR("failed to int hal interface");
+               hal_radio_put_backend(radio->hal_radio);
                ret = __convert_error_code(ret, (char *)__FUNCTION__);
                goto ERROR_HAL_INIT;
        }
@@ -395,12 +404,16 @@ int _mmradio_destroy(mm_radio_t *radio)
        if (radio->msg_queue)
                g_async_queue_unref(radio->msg_queue);
 
-       ret = radio_hal_interface_deinit(radio->hal_inf);
+       ret = hal_radio_deinit(radio->hal_radio);
        if (ret) {
-               MMRADIO_LOG_ERROR("failed to deinitialize radio hal interface");
+               MMRADIO_LOG_ERROR("failed to deinitialize radio hal");
                return __convert_error_code(ret, (char *)__FUNCTION__);
        }
 
+       ret = hal_radio_put_backend(radio->hal_radio);
+       if (ret)
+               MMRADIO_LOG_ERROR("failed to put radio hal backend");
+
        ret = mm_resource_manager_destroy(radio->resource_manager);
        if (ret) {
                MMRADIO_LOG_ERROR("failed to destroy resource manager");
@@ -426,7 +439,7 @@ int _mmradio_set_frequency(mm_radio_t *radio, int freq)
 
        radio->freq = freq;
 
-       ret = radio_hal_set_frequency(radio->hal_inf, freq);
+       ret = hal_radio_set_frequency(radio->hal_radio, freq);
        if (ret) {
                MMRADIO_LOG_ERROR("failed to set radio hal frequency");
                return __convert_error_code(ret, (char *)__FUNCTION__);
@@ -449,7 +462,7 @@ int _mmradio_get_frequency(mm_radio_t *radio, int *pFreq)
 
        MMRADIO_RETURN_VAL_IF_FAIL(pFreq, MM_ERROR_INVALID_ARGUMENT);
 
-       ret = radio_hal_get_frequency(radio->hal_inf, &freq);
+       ret = hal_radio_get_frequency(radio->hal_radio, &freq);
        if (ret) {
                MMRADIO_LOG_ERROR("failed to get radio hal frequency");
                *pFreq = 0;
@@ -495,7 +508,6 @@ int _mmradio_unmute(mm_radio_t *radio)
                sound_manager_set_virtual_stream_volume(radio->vstream,
                        (double)radio->local_volume);
 
-
        radio->is_muted = false;
        MMRADIO_LOG_INFO("Radio mute state [%d]", radio->is_muted);
        MMRADIO_LOG_FLEAVE();
@@ -549,73 +561,38 @@ int _mmradio_start(mm_radio_t *radio)
        MMRADIO_LOG_INFO("now tune to frequency : %d", radio->freq);
 
        if (!radio->is_ready) {
-               ret = mm_resource_manager_mark_for_acquire(radio->resource_manager,
-                       MM_RESOURCE_MANAGER_RES_TYPE_RADIO,
-                       MM_RESOURCE_MANAGER_RES_VOLUME_FULL, &radio->radio_resource);
-               if (ret != MM_RESOURCE_MANAGER_ERROR_NONE) {
-                       MMRADIO_LOG_ERROR("resource manager mark for acquire fail");
-                       return MM_ERROR_RADIO_INTERNAL;
-               }
-
-               radio->interrupted_by_resource_conflict = FALSE;
-               ret = mm_resource_manager_commit(radio->resource_manager);
-               if (ret != MM_RESOURCE_MANAGER_ERROR_NONE) {
-                       MMRADIO_LOG_ERROR("failed to commit resource manager");
-                       mm_resource_manager_mark_for_release(radio->resource_manager,
-                               radio->radio_resource);
-                       radio->radio_resource = NULL;
-                       return ret;
-               }
-
-               ret = radio_hal_prepare(radio->hal_inf);
-               if (ret) {
-                       ret = __convert_error_code(ret, (char *)__FUNCTION__);
-                       if (ret == MM_ERROR_NOT_IMPLEMENTED) {
-                               MMRADIO_LOG_WARNING("radio_hal_prepare is not supported");
-                       } else {
-                               MMRADIO_LOG_ERROR("failed to prepare radio hal");
-                               goto error2;
-                       }
-               }
 
-               ret = radio_hal_open(radio->hal_inf);
-               if (ret) {
-                       ret = __convert_error_code(ret, (char *)__FUNCTION__);
-                       if (ret == MM_ERROR_NOT_IMPLEMENTED) {
-                               MMRADIO_LOG_WARNING("radio_hal_open is not supported");
-                       } else {
-                               MMRADIO_LOG_ERROR("failed to open radio hal");
-                               goto error1;
-                       }
-               }
-               radio->is_ready = true;
        } else {
                MMRADIO_LOG_DEBUG("radio prepared and opened");
        }
 
-       ret = radio_hal_start(radio->hal_inf);
+       ret = __mmradio_prepare_radio_device(radio);
+       if (ret != MM_ERROR_NONE)
+               return ret;
+
+       ret = hal_radio_start(radio->hal_radio);
        if (ret) {
                ret = __convert_error_code(ret, (char *)__FUNCTION__);
                if (ret == MM_ERROR_NOT_IMPLEMENTED) {
-                       MMRADIO_LOG_WARNING("radio_hal_start is not supported");
+                       MMRADIO_LOG_WARNING("hal_radio_start is not supported");
                } else {
                        MMRADIO_LOG_ERROR("failed to start radio hal");
-                       goto error1;
+                       goto error;
                }
        }
 
        /* set stored frequency */
-       ret = radio_hal_set_frequency(radio->hal_inf, radio->freq);
+       ret = hal_radio_set_frequency(radio->hal_radio, radio->freq);
        if (ret) {
                MMRADIO_LOG_ERROR("failed to set radio hal frequency");
                ret = __convert_error_code(ret, (char *)__FUNCTION__);
-               goto error1;
+               goto error;
        }
 
        ret = sound_manager_start_virtual_stream(radio->vstream);
        if (ret) {
                MMRADIO_LOG_ERROR("failed to start sound manager virtual stream");
-               goto error1;
+               goto error;
        }
 
        if (radio->vstream) {
@@ -632,10 +609,22 @@ int _mmradio_start(mm_radio_t *radio)
 
        return MM_ERROR_NONE;
 
-error1:
-       radio_hal_close(radio->hal_inf);
-error2:
-       radio_hal_unprepare(radio->hal_inf);
+error:
+       hal_radio_close(radio->hal_radio);
+       hal_radio_unprepare(radio->hal_radio);
+
+       if (!radio->interrupted_by_resource_conflict && /* is being released */
+               radio->radio_resource != NULL) {
+               if (mm_resource_manager_mark_for_release(radio->resource_manager,
+                       radio->radio_resource) != MM_RESOURCE_MANAGER_ERROR_NONE)
+                       MMRADIO_LOG_ERROR("failed to mark resource for release, ret(0x%x)", ret);
+               radio->radio_resource = NULL;
+
+       }
+       if (mm_resource_manager_commit(radio->resource_manager)
+               != MM_RESOURCE_MANAGER_ERROR_NONE)
+               MMRADIO_LOG_ERROR("resource manager commit fail");
+
        radio->is_ready = false;
        return ret;
 }
@@ -658,11 +647,11 @@ int _mmradio_stop(mm_radio_t *radio)
                return ret;
        }
 
-       ret = radio_hal_stop(radio->hal_inf);
+       ret = hal_radio_stop(radio->hal_radio);
        if (ret) {
                ret = __convert_error_code(ret, (char *)__FUNCTION__);
                if (ret == MM_ERROR_NOT_IMPLEMENTED) {
-                       MMRADIO_LOG_WARNING("radio_hal_stop is not supported");
+                       MMRADIO_LOG_WARNING("hal_radio_stop is not supported");
                } else {
                        MMRADIO_LOG_ERROR("failed to stop radio hal");
                        return ret;
@@ -671,22 +660,22 @@ int _mmradio_stop(mm_radio_t *radio)
 
        if (radio->is_ready) {
                /* close radio device here !!!! */
-               ret = radio_hal_close(radio->hal_inf);
+               ret = hal_radio_close(radio->hal_radio);
                if (ret) {
                        ret = __convert_error_code(ret, (char *)__FUNCTION__);
                        if (ret == MM_ERROR_NOT_SUPPORT_API) {
-                               MMRADIO_LOG_WARNING("radio_hal_close is not supported");
+                               MMRADIO_LOG_WARNING("hal_radio_close is not supported");
                        } else {
                                MMRADIO_LOG_ERROR("failed to close radio hal");
                                return ret;
                        }
                }
 
-               ret = radio_hal_unprepare(radio->hal_inf);
+               ret = hal_radio_unprepare(radio->hal_radio);
                if (ret) {
                        ret = __convert_error_code(ret, (char *)__FUNCTION__);
                        if (ret == MM_ERROR_NOT_SUPPORT_API) {
-                               MMRADIO_LOG_WARNING("radio_hal_unprepare is not supported");
+                               MMRADIO_LOG_WARNING("hal_radio_unprepare is not supported");
                        } else {
                                MMRADIO_LOG_ERROR("failed to unprepare radio hal");
                                return ret;
@@ -789,51 +778,12 @@ int _mmradio_start_scan(mm_radio_t *radio)
 
        p_thread->stop = false;
 
-       if (!radio->is_ready) {
-               ret = mm_resource_manager_mark_for_acquire(radio->resource_manager,
-                       MM_RESOURCE_MANAGER_RES_TYPE_RADIO,
-                       MM_RESOURCE_MANAGER_RES_VOLUME_FULL, &radio->radio_resource);
-               if (ret != MM_RESOURCE_MANAGER_ERROR_NONE) {
-                       MMRADIO_LOG_ERROR("resource manager mark for acquire fail");
-                       return MM_ERROR_RADIO_INTERNAL;
-               }
-
-               radio->interrupted_by_resource_conflict = FALSE;
-               ret = mm_resource_manager_commit(radio->resource_manager);
-               if (ret != MM_RESOURCE_MANAGER_ERROR_NONE) {
-                       MMRADIO_LOG_ERROR("failed to commit resource manager");
-                       mm_resource_manager_mark_for_release(radio->resource_manager,
-                               radio->radio_resource);
-                       radio->radio_resource = NULL;
-                       return ret;
-               }
-
-               ret = radio_hal_prepare(radio->hal_inf);
-               if (ret) {
-                       ret = __convert_error_code(ret, (char *)__FUNCTION__);
-                       if (ret == MM_ERROR_NOT_IMPLEMENTED) {
-                               MMRADIO_LOG_WARNING("radio_hal_prepare is not supported");
-                       } else {
-                               MMRADIO_LOG_ERROR("failed to prepare radio hal");
-                               return ret;
-                       }
-               }
-
-               ret = radio_hal_open(radio->hal_inf);
-               if (ret) {
-                       ret = __convert_error_code(ret, (char *)__FUNCTION__);
-                       if (ret == MM_ERROR_NOT_IMPLEMENTED) {
-                               MMRADIO_LOG_WARNING("radio_hal_open is not supported");
-                       } else {
-                               MMRADIO_LOG_ERROR("failed to open radio hal");
-                               return ret;
-                       }
-               }
-
-               radio->is_ready = true;
-       } else {
-               MMRADIO_LOG_DEBUG("radio prepared and opened");
+       ret = __mmradio_prepare_radio_device(radio);
+       if (ret != MM_ERROR_NONE) {
+               LOGE("Failed to prepare radio device");
+               return ret;
        }
+
        MMRADIO_THREAD_LOCK(p_thread);
 
        p_thread->is_running = true;
@@ -873,11 +823,11 @@ int _mm_radio_get_signal_strength(mm_radio_t *radio, int *value)
        MMRADIO_RETURN_VAL_IF_FAIL(value, MM_ERROR_INVALID_ARGUMENT);
 
        /* just return stored frequency if radio device is not ready */
-       ret = radio_hal_get_signal_strength(radio->hal_inf, &strength);
+       ret = hal_radio_get_signal_strength(radio->hal_radio, &strength);
        if (ret) {
                ret = __convert_error_code(ret, (char *)__FUNCTION__);
                if (ret == MM_ERROR_NOT_IMPLEMENTED)
-                       MMRADIO_LOG_WARNING("radio_hal_get_signal_strength is not supported");
+                       MMRADIO_LOG_WARNING("hal_radio_get_signal_strength is not supported");
                else
                        MMRADIO_LOG_ERROR("failed to get radio hal signal strength");
                *value = 0;
@@ -923,7 +873,7 @@ void __mmradio_scan_thread(mm_radio_t *radio)
                        }
                }
 
-               ret = radio_hal_set_frequency(radio->hal_inf, radio->region_setting.band_min);
+               ret = hal_radio_set_frequency(radio->hal_radio, radio->region_setting.band_min);
                if (ret)
                        goto FINISHED;
 
@@ -947,7 +897,7 @@ void __mmradio_scan_thread(mm_radio_t *radio)
                        }
 
                        MMRADIO_HAL_SEEK_THREAD_LOCK(radio);
-                       ret = radio_hal_seek(radio->hal_inf, MM_RADIO_SEEK_UP);
+                       ret = hal_radio_seek(radio->hal_radio, MM_RADIO_SEEK_UP);
                        MMRADIO_HAL_SEEK_THREAD_UNLOCK(radio);
                        if (ret) {
                                MMRADIO_LOG_ERROR("radio scanning error");
@@ -965,7 +915,7 @@ void __mmradio_scan_thread(mm_radio_t *radio)
                        }
 
                        /* now we can get new frequency from radio device */
-                       ret = radio_hal_get_frequency(radio->hal_inf, &freq);
+                       ret = hal_radio_get_frequency(radio->hal_radio, &freq);
                        if (ret) {
                                MMRADIO_LOG_ERROR("failed to get current frequency");
                        } else {
@@ -1002,7 +952,7 @@ FINISHED:
                                MMRADIO_LOG_ERROR("failed to set radio unmute");
                                goto FINISHED_ERR;
                        }
-                       ret = radio_hal_set_frequency(radio->hal_inf, prev_freq);
+                       ret = hal_radio_set_frequency(radio->hal_radio, prev_freq);
                        if (ret) {
                                MMRADIO_LOG_ERROR("failed to set radio hal frequency");
                                goto FINISHED_ERR;
@@ -1097,7 +1047,7 @@ void __mmradio_seek_thread(mm_radio_t *radio)
                MMRADIO_LOG_DEBUG("try to seek ");
                MMRADIO_HAL_SEEK_THREAD_LOCK(radio);
                MMRADIO_LOG_DEBUG("seek start");
-               ret = radio_hal_seek(radio->hal_inf, radio->seek_direction);
+               ret = hal_radio_seek(radio->hal_radio, radio->seek_direction);
                MMRADIO_HAL_SEEK_THREAD_UNLOCK(radio);
                if (ret) {
                        MMRADIO_LOG_ERROR("failed to seek radio hal");
@@ -1115,7 +1065,7 @@ void __mmradio_seek_thread(mm_radio_t *radio)
                }
 
                /* now we can get new frequency from radio device */
-               ret = radio_hal_get_frequency(radio->hal_inf, &freq);
+               ret = hal_radio_get_frequency(radio->hal_radio, &freq);
                if (ret) {
                        MMRADIO_LOG_ERROR("failed to get current frequency");
                        goto SEEK_FAILED;
@@ -1132,7 +1082,7 @@ void __mmradio_seek_thread(mm_radio_t *radio)
                /* check if it's limit freq or not */
                if (__is_tunable_frequency(radio, freq)) {
                        /* now tune to new frequency */
-                       ret = radio_hal_set_frequency(radio->hal_inf, freq);
+                       ret = hal_radio_set_frequency(radio->hal_radio, freq);
                        if (ret) {
                                MMRADIO_LOG_ERROR("failed to tune to new frequency");
                                goto SEEK_FAILED;
@@ -1430,8 +1380,6 @@ int _mmradio_get_channel_spacing(mm_radio_t *radio, unsigned int *ch_spacing)
 
 int _mmradio_set_volume(mm_radio_t *radio, float volume)
 {
-       int ret = MM_ERROR_NONE;
-
        MMRADIO_LOG_FENTER();
 
        MMRADIO_CHECK_INSTANCE(radio);
@@ -1450,7 +1398,7 @@ int _mmradio_set_volume(mm_radio_t *radio, float volume)
 
        MMRADIO_LOG_FLEAVE();
 
-       return ret;
+       return MM_ERROR_NONE;
 }
 
 int _mmradio_get_volume(mm_radio_t *radio, float *pVolume)
@@ -1744,6 +1692,96 @@ void __mmradio_msg_thread(mm_radio_t *radio)
        pthread_exit(NULL);
 }
 
+static int __mmradio_prepare_radio_device(mm_radio_t *radio)
+{
+#define MAX_ENV_LEN 64
+       int ret = MM_ERROR_NONE;
+       int stream_index = 0;
+       char env_str[MAX_ENV_LEN] = {0, };
+
+       MMRADIO_LOG_FENTER();
+       MMRADIO_CHECK_INSTANCE(radio);
+
+       if (radio->is_ready) {
+               MMRADIO_LOG_DEBUG("radio prepared and opened");
+               return ret;
+       }
+
+       ret = mm_resource_manager_mark_for_acquire(radio->resource_manager,
+               MM_RESOURCE_MANAGER_RES_TYPE_RADIO,
+               MM_RESOURCE_MANAGER_RES_VOLUME_FULL, &radio->radio_resource);
+       if (ret != MM_RESOURCE_MANAGER_ERROR_NONE) {
+               MMRADIO_LOG_ERROR("resource manager mark for acquire fail");
+               return MM_ERROR_RADIO_INTERNAL;
+       }
+
+       radio->interrupted_by_resource_conflict = FALSE;
+       ret = mm_resource_manager_commit(radio->resource_manager);
+       if (ret != MM_RESOURCE_MANAGER_ERROR_NONE) {
+               MMRADIO_LOG_ERROR("failed to commit resource manager");
+               mm_resource_manager_mark_for_release(radio->resource_manager,
+                       radio->radio_resource);
+               radio->radio_resource = NULL;
+               return ret;
+       }
+
+       sound_manager_get_index_from_stream_information(radio->stream_info, &stream_index);
+       MMRADIO_LOG_DEBUG("radio stream index is %d", stream_index);
+       snprintf(env_str, sizeof(env_str) - 1, "%d", stream_index);
+       /* for radio emulator volume control */
+       if (setenv("RADIO_STREAM_INDEX", env_str, 1) != 0)
+               MMRADIO_LOG_INFO("Failed to set environmental variable");
+
+       ret = hal_radio_prepare(radio->hal_radio);
+       if (ret) {
+               ret = __convert_error_code(ret, (char *)__FUNCTION__);
+               if (ret == MM_ERROR_NOT_IMPLEMENTED) {
+                       MMRADIO_LOG_WARNING("hal_radio_prepare is not supported");
+                       ret = MM_ERROR_NONE;
+               } else {
+                       MMRADIO_LOG_ERROR("failed to prepare radio hal");
+                       goto error2;
+               }
+       }
+
+       ret = hal_radio_open(radio->hal_radio);
+       if (ret) {
+               ret = __convert_error_code(ret, (char *)__FUNCTION__);
+               if (ret == MM_ERROR_NOT_IMPLEMENTED) {
+                       MMRADIO_LOG_WARNING("hal_radio_open is not supported");
+                       ret = MM_ERROR_NONE;
+               } else {
+                       MMRADIO_LOG_ERROR("failed to open radio hal");
+                       goto error1;
+               }
+       }
+       radio->is_ready = true;
+
+       return ret;
+
+error1:
+       hal_radio_close(radio->hal_radio);
+
+error2:
+       hal_radio_unprepare(radio->hal_radio);
+
+       if (!radio->interrupted_by_resource_conflict && /* is being released */
+               radio->radio_resource != NULL) {
+               if (mm_resource_manager_mark_for_release(radio->resource_manager,
+                       radio->radio_resource) != MM_RESOURCE_MANAGER_ERROR_NONE)
+                       MMRADIO_LOG_ERROR("failed to mark resource for release, ret(0x%x)", ret);
+               radio->radio_resource = NULL;
+
+       }
+
+       if (mm_resource_manager_commit(radio->resource_manager)
+               != MM_RESOURCE_MANAGER_ERROR_NONE)
+               MMRADIO_LOG_ERROR("resource manager commit fail");
+
+       radio->is_ready = false;
+       return ret;
+}
+
 static void __mmradio_close_radio_device(mm_radio_t *radio)
 {
        int ret = MM_ERROR_NONE;
@@ -1756,18 +1794,18 @@ static void __mmradio_close_radio_device(mm_radio_t *radio)
                return;
        }
 
-       ret = radio_hal_close(radio->hal_inf);
+       ret = hal_radio_close(radio->hal_radio);
        if (ret)
                __convert_error_code(ret, (char *)__FUNCTION__);
 
-       ret = radio_hal_unprepare(radio->hal_inf);
+       ret = hal_radio_unprepare(radio->hal_radio);
        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);
                radio->radio_resource = NULL;
                if (ret != MM_RESOURCE_MANAGER_ERROR_NONE)
                        MMRADIO_LOG_ERROR("failed to mark resource for release, ret(0x%x)", ret);
diff --git a/src/radio_hal_interface.c b/src/radio_hal_interface.c
deleted file mode 100644 (file)
index 6fbfd6a..0000000
+++ /dev/null
@@ -1,317 +0,0 @@
-/*
- * 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 function");
-                       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 */
-