Remove radio volume logic for media volume
[platform/core/multimedia/libmm-radio.git] / src / include / mm_radio_priv.h
index 419316e..1c88fe2 100644 (file)
@@ -1,9 +1,7 @@
 /*
- * libmm-radio
+ * mm_radio_priv.h
  *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: JongHyuk Choi <jhchoi.choi@samsung.com>, YoungHwan An <younghwan_.an@samsung.com>
+ * 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.
@@ -18,7 +16,7 @@
  * limitations under the License.
  *
  */
+
 #ifndef __MM_Radio_INTERNAL_H__
 #define        __MM_Radio_INTERNAL_H__
 
 
 #include <mm_types.h>
 #include <mm_message.h>
+#include <media/mm_resource_manager.h>
 
-#include "mm_radio_asm.h"
 #include "mm_radio.h"
 #include "mm_radio_utils.h"
 #include <linux/videodev2.h>
 
 #include <gst/gst.h>
 #include <gst/gstbuffer.h>
+
+#include <glib.h>
+
 #ifdef __cplusplus
        extern "C" {
 #endif
@@ -54,7 +54,7 @@
 /*---------------------------------------------------------------------------
     GLOBAL #defines:
 ---------------------------------------------------------------------------*/
-#define SAMPLEDELAY            15000
+#define SAMPLEDELAY                                    15000
 
 /* si470x dependent define */
 #define SYSCONFIG1                                     4               /* System Configuration 1 */
@@ -76,8 +76,7 @@
 /*---------------------------------------------------------------------------
     GLOBAL CONSTANT DEFINITIONS:
 ---------------------------------------------------------------------------*/
-typedef enum
-{
+typedef enum {
        MMRADIO_COMMAND_CREATE = 0,
        MMRADIO_COMMAND_DESTROY,
        MMRADIO_COMMAND_REALIZE,
@@ -93,39 +92,71 @@ typedef enum
        MMRADIO_COMMAND_SEEK,
        MMRADIO_COMMAND_SET_REGION,
        MMRADIO_COMMAND_GET_REGION,
+       MMRADIO_COMMAND_SET_VOLUME,
+       MMRADIO_COMMAND_GET_VOLUME,
        MMRADIO_COMMAND_NUM
 } MMRadioCommand;
 
 /* max and mix frequency types, KHz */
-typedef enum
-{
+typedef enum {
        MM_RADIO_FREQ_NONE                              = 0,
        /* min band types */
-       MM_RADIO_FREQ_MIN_76100_KHZ             = 76100,
-       MM_RADIO_FREQ_MIN_87500_KHZ             = 87500,
-       MM_RADIO_FREQ_MIN_88100_KHZ             = 88100,
+       MM_RADIO_FREQ_MIN_76100_KHZ             = 76100,
+       MM_RADIO_FREQ_MIN_87500_KHZ             = 87500,
+       MM_RADIO_FREQ_MIN_88100_KHZ             = 88100,
        /* max band types */
        MM_RADIO_FREQ_MAX_89900_KHZ             = 89900,
        MM_RADIO_FREQ_MAX_108000_KHZ    = 108000,
-}MMRadioFreqTypes;
+} MMRadioFreqTypes;
 
 /* de-emphasis types  */
-typedef enum
-{
+typedef enum {
        MM_RADIO_DEEMPHASIS_NONE = 0,
        MM_RADIO_DEEMPHASIS_50_US,
        MM_RADIO_DEEMPHASIS_75_US,
-}MMRadioDeemphasis;
+} MMRadioDeemphasis;
 
 /* radio region settings */
-typedef struct
-{
+typedef struct {
        MMRadioRegionType country;
        MMRadioDeemphasis deemphasis;   // unit :  us
        MMRadioFreqTypes band_min;              // <- freq. range, unit : KHz
        MMRadioFreqTypes band_max;              // ->
-       //int channel_spacing;                          // TBD
-}MMRadioRegion_t;
+       int channel_spacing;                            // TBD
+} MMRadioRegion_t;
+
+typedef struct {
+       pthread_t thread;
+       pthread_mutex_t mutex;
+       pthread_cond_t cond;
+       int thread_id;
+       bool is_running;
+       bool stop;
+       bool thread_exit;
+} MMRadioThread_t;
+
+typedef enum {
+       MM_RADIO_MSG_DESTROY = 0,
+       MM_RADIO_MSG_SCAN_INFO,
+       MM_RADIO_MSG_SCAN_STOPPED,
+       MM_RADIO_MSG_SCAN_FINISHED,
+       MM_RADIO_MSG_SEEK_FINISHED,
+       MM_RADIO_MSG_STATE_INTERRUPTED,
+       MM_RADIO_MSG_NUM
+} MMRadioMsgTypes;
+
+typedef struct {
+       bool destroy;
+       MMRadioMsgTypes msg_type;
+       int data;
+} mm_radio_msg_t;
+
+typedef enum {
+       MM_RADIO_THREAD_MSG = 0,
+       MM_RADIO_THREAD_SEEK,
+       MM_RADIO_THREAD_SCAN,
+       MM_RADIO_THREAD_NUM
+} MMRadioThreadTypes;
 
 /*---------------------------------------------------------------------------
     GLOBAL DATA TYPE DEFINITIONS:
@@ -133,13 +164,12 @@ typedef struct
 #define USE_GST_PIPELINE
 
 #ifdef USE_GST_PIPELINE
-typedef struct _mm_radio_gstreamer_s
-{
+typedef struct _mm_radio_gstreamer_s {
        GMainLoop *loop;
        GstElement *pipeline;
-       GstElement *avsysaudiosrc;
+       GstElement *audiosrc;
        GstElement *queue2;
-       GstElement *avsysaudiosink;
+       GstElement *audiosink;
        GstBuffer *output_buffer;
 } mm_radio_gstreamer_s;
 #endif
@@ -158,7 +188,10 @@ typedef struct {
        /* radio attributes */
        MMHandleType* attrs;
 
+       MMRadioThread_t thread[MM_RADIO_THREAD_NUM];
+
        /* message callback */
+       GAsyncQueue *msg_queue;
        MMMessageCallback msg_cb;
        void* msg_cb_param;
 
@@ -174,22 +207,19 @@ typedef struct {
        /* hw debug */
        struct v4l2_dbg_register reg;
 
-       /* scan */
-       pthread_t       scan_thread;
-       bool    stop_scan;
-
        /* seek */
-       pthread_t seek_thread;
        int prev_seek_freq;
        MMRadioSeekDirectionType seek_direction;
 
-       /* ASM */
-       MMRadioASM sm;
-
        int freq;
 #ifdef USE_GST_PIPELINE
        mm_radio_gstreamer_s* pGstreamer_s;
 #endif
+       mm_resource_manager_h resource_manager;
+       mm_resource_manager_res_h radio_resource;
+       int interrupted_by_resource_conflict;
+
+       float local_volume;
 
        /* region settings */
        MMRadioRegion_t region_setting;
@@ -198,34 +228,34 @@ typedef struct {
 /*===========================================================================================
   GLOBAL FUNCTION PROTOTYPES
 ========================================================================================== */
-int _mmradio_create_radio(mm_radio_t* radio);
-int _mmradio_destroy(mm_radio_t* radio);
-int _mmradio_realize(mm_radio_t* radio);
-int _mmradio_unrealize(mm_radio_t* radio);
-int _mmradio_set_message_callback(mm_radio_t* radio, MMMessageCallback callback, void *user_param);
-int _mmradio_get_state(mm_radio_t* radio, int* pState);
-int _mmradio_set_frequency(mm_radio_t* radio, int freq);
-int _mmradio_get_frequency(mm_radio_t* radio, int* pFreq);
-int _mmradio_mute(mm_radio_t* radio);
-int _mmradio_unmute(mm_radio_t* radio);
-int _mmradio_start(mm_radio_t* radio);
-int _mmradio_stop(mm_radio_t* radio);
-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 _mmradio_create_radio(mm_radio_t *radio);
+int _mmradio_destroy(mm_radio_t *radio);
+int _mmradio_realize(mm_radio_t *radio);
+int _mmradio_unrealize(mm_radio_t *radio);
+int _mmradio_set_message_callback(mm_radio_t *radio, MMMessageCallback callback, void *user_param);
+int _mmradio_get_state(mm_radio_t *radio, int *pState);
+int _mmradio_set_frequency(mm_radio_t *radio, int freq);
+int _mmradio_get_frequency(mm_radio_t *radio, int *pFreq);
+int _mmradio_mute(mm_radio_t *radio);
+int _mmradio_unmute(mm_radio_t *radio);
+int _mmradio_start(mm_radio_t *radio);
+int _mmradio_stop(mm_radio_t *radio);
+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);
-#if 0
-int mmradio_set_attrs(mm_radio_t*  radio, MMRadioAttrsType type, MMHandleType attrs);
-MMHandleType mmradio_get_attrs(mm_radio_t*  radio, MMRadioAttrsType type);
+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);
+int _mmradio_get_channel_spacing(mm_radio_t *radio, unsigned int *ch_spacing);
+int _mmradio_set_volume(mm_radio_t *radio, float volume);
+int _mmradio_get_volume(mm_radio_t *radio, float *pVolume);
 
 #ifdef __cplusplus
        }