From: Sangjin Sim Date: Mon, 1 Jun 2015 02:06:24 +0000 (+0900) Subject: Sync with latest src tizen2.4 X-Git-Tag: accepted/tizen/common/20150608.090605^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b888cc93ce17b9b099486fbc3689ea6327305a3e;p=platform%2Fcore%2Fmultimedia%2Flibmm-radio.git Sync with latest src tizen2.4 Change-Id: Ifee387f35cae1fc56328487d2b121f83f6950121 --- diff --git a/src/include/mm_radio.h b/src/include/mm_radio.h index dba7d56..f160b23 100644 --- a/src/include/mm_radio.h +++ b/src/include/mm_radio.h @@ -38,7 +38,7 @@ This part describes the APIs with respect to play radio */ - + /** * Enumerations of radio state. @@ -81,8 +81,8 @@ typedef enum { /** * This function creates a radio handle. \n - * So, application can make radio instance and initializes it. - * + * So, application can make radio instance and initializes it. + * * * @param hradio [out] Handle of radio. * @@ -302,7 +302,7 @@ int mm_radio_create(MMHandleType *hradio); /** * This function deletes radio handle. \n - * It closes radio device and releases all resources allocated. + * It closes radio device and releases all resources allocated. * * @param hradio [in] Handle of radio. * @@ -310,7 +310,7 @@ int mm_radio_create(MMHandleType *hradio); * @pre Application can use this API at any state. * @post None * @remark None - * @see mm_radio_create mm_radio_realize mm_radio_unrealize mm_radio_start mm_radio_stop + * @see mm_radio_create mm_radio_realize mm_radio_unrealize mm_radio_start mm_radio_stop * @par Example * @code #include @@ -741,7 +741,7 @@ int mm_radio_realize(MMHandleType hradio); /** * This function mutes tuner and closes the radio device. - * And, application can destroy radio directly without this API. + * And, application can destroy radio directly without this API. * * @param hradio [in] Handle of radio. * @@ -1396,7 +1396,7 @@ int main(int argc, char **argv) __call_api( choosen ); } } - * @endcode + * @endcode */ int mm_radio_get_state(MMHandleType hradio, MMRadioStateType *state); @@ -1616,7 +1616,7 @@ int main(int argc, char **argv) } } - * @endcode + * @endcode */ int mm_radio_start(MMHandleType hradio); @@ -1836,7 +1836,7 @@ int main(int argc, char **argv) } } - * @endcode + * @endcode */ int mm_radio_stop(MMHandleType hradio); @@ -1846,8 +1846,8 @@ int mm_radio_stop(MMHandleType hradio); * MM_MESSAGE_RADIO_SEEK_START will be sent when this function is called. \n * And if one valid frequency is found, MM_MESSAGE_RADIO_SEEK_FINISH will be sent. \n * It doesn't support wrap_around to prevent looping when there is no any valid frequency. \n - * So, we will notice the limit of band as 87.5Mhz or 108Mhz. - * In this case, applicaion can take two scenario. + * So, we will notice the limit of band as 87.5Mhz or 108Mhz. + * In this case, applicaion can take two scenario. * One is to seek continually in the same direction. The other is to set previous frequency. * * @param hradio [in] Handle of radio. @@ -2064,7 +2064,7 @@ int main(int argc, char **argv) } } - * @endcode + * @endcode */ int mm_radio_seek(MMHandleType hradio, MMRadioSeekDirectionType direction); @@ -2285,7 +2285,7 @@ int main(int argc, char **argv) } } - * @endcode + * @endcode */ int mm_radio_set_frequency(MMHandleType hradio, int freq); @@ -2506,21 +2506,21 @@ int main(int argc, char **argv) } } - * @endcode + * @endcode */ int mm_radio_get_frequency(MMHandleType hradio, int* pFreq); /** * This function is to start for getting all effective frequencies. \n - * So, if a frequency is found, MM_MESSAGE_RADIO_SCAN_INFO will be posted with frequency information. - * If there is no frequency, we will post MM_MESSAGE_RADIO_SCAN_FINISH. - * And then, the radio state will be changed as MM_RADIO_STATE_READY. + * So, if a frequency is found, MM_MESSAGE_RADIO_SCAN_INFO will be posted with frequency information. + * If there is no frequency, we will post MM_MESSAGE_RADIO_SCAN_FINISH. + * And then, the radio state will be changed as MM_RADIO_STATE_READY. * * @param hradio [in] Handle of radio. * * @return This function returns zero on success, or negative value with errors * @pre MM_RADIO_STATE_READY - * @post MM_RADIO_STATE_SCANNING + * @post MM_RADIO_STATE_SCANNING * @remark None * @see mm_radio_scan_stop * @par Example @@ -2729,13 +2729,13 @@ int main(int argc, char **argv) } } - * @endcode + * @endcode */ int mm_radio_scan_start(MMHandleType hradio); /** * This function is to stop for getting all the effective frequencies. \n - * So, application can use this API to stop in the middle of scanning. + * So, application can use this API to stop in the middle of scanning. * * @param hradio [in] Handle of radio. * @@ -2950,7 +2950,7 @@ int main(int argc, char **argv) } } - * @endcode + * @endcode */ int mm_radio_scan_stop(MMHandleType hradio); @@ -2964,7 +2964,7 @@ int mm_radio_scan_stop(MMHandleType hradio); * @pre None * @post None * @remark None - * @see + * @see * @par Example * @code #include @@ -3003,7 +3003,7 @@ int __menu(void) printf("[12] mm_radio_get_frequency\n"); printf("[13] mm_radio_scan_start\n"); printf("[14] mm_radio_scan_stop\n"); - printf("[16] mm_radio_set_mute\n"); + printf("[16] mm_radio_set_mute\n"); printf("[0] quit\n"); printf("---------------------------------------------------------\n"); printf("choose one : "); @@ -3180,7 +3180,7 @@ int main(int argc, char **argv) } } - * @endcode + * @endcode */ int mm_radio_set_mute(MMHandleType hradio, bool muted); /** @@ -3443,10 +3443,24 @@ int mm_radio_get_region_type(MMHandleType hradio, MMRadioRegionType *type); int mm_radio_get_region_frequency_range(MMHandleType hradio, unsigned int *min, unsigned int *max); /** + * This function is to get channel spacing. + * + * @param hradio [in] Handle of radio. + * @param channel_spacing [out] channel spacing value + * + * @return This function returns zero on success, or negative value with errors + * @pre None + * @post None + * @see mm_radio_get_region_type() + */ +int mm_radio_get_channel_spacing(MMHandleType hradio, int *channel_spacing); + + +/** @} */ - + #ifdef __cplusplus } #endif diff --git a/src/include/mm_radio_priv.h b/src/include/mm_radio_priv.h index 402da56..bd070ae 100644 --- a/src/include/mm_radio_priv.h +++ b/src/include/mm_radio_priv.h @@ -124,7 +124,7 @@ typedef struct MMRadioDeemphasis deemphasis; // unit : us MMRadioFreqTypes band_min; // <- freq. range, unit : KHz MMRadioFreqTypes band_max; // -> - //int channel_spacing; // TBD + int channel_spacing; // TBD }MMRadioRegion_t; /*--------------------------------------------------------------------------- @@ -137,10 +137,10 @@ typedef struct _mm_radio_gstreamer_s { GMainLoop *loop; GstElement *pipeline; - GstElement *avsysaudiosrc; + GstElement *audiosrc; GstElement *queue2; GstElement *volume; - GstElement *avsysaudiosink; + GstElement *audiosink; GstBuffer *output_buffer; } mm_radio_gstreamer_s; #endif diff --git a/src/mm_radio.c b/src/mm_radio.c index ac93895..8c1a9e6 100755 --- a/src/mm_radio.c +++ b/src/mm_radio.c @@ -177,11 +177,20 @@ int mm_radio_unrealize(MMHandleType hradio) { int result = MM_ERROR_NONE; mm_radio_t* radio = (mm_radio_t*)hradio; + MMRadioStateType state = 0; MMRADIO_LOG_FENTER(); return_val_if_fail(radio, MM_ERROR_RADIO_NOT_INITIALIZED); + mm_radio_get_state((hradio), &state); + MMRADIO_LOG_DEBUG("mm_radio_unrealize state: %d\n", state); + + if(state == MM_RADIO_STATE_SCANNING) + { + mm_radio_scan_stop(hradio); + } + MMRADIO_CMD_LOCK( radio ); result = _mmradio_unrealize( radio ); @@ -477,3 +486,26 @@ int mm_radio_get_region_frequency_range(MMHandleType hradio, unsigned int *min, return result; } +int mm_radio_get_channel_spacing(MMHandleType hradio, int *channel_spacing) +{ + MMRADIO_LOG_FENTER(); + + return_val_if_fail(hradio, MM_ERROR_RADIO_NOT_INITIALIZED); + return_val_if_fail(channel_spacing, MM_ERROR_INVALID_ARGUMENT); + + int result = MM_ERROR_NONE; + mm_radio_t* radio = (mm_radio_t*)hradio; + unsigned int ch_spacing = 0; + + result = _mmradio_get_channel_spacing(radio, &ch_spacing); + + if (result == MM_ERROR_NONE) + { + *channel_spacing = ch_spacing; + } + + MMRADIO_LOG_FLEAVE(); + return result; +} + + diff --git a/src/mm_radio_priv.c b/src/mm_radio_priv.c index b662cfd..7a58de3 100755 --- a/src/mm_radio_priv.c +++ b/src/mm_radio_priv.c @@ -95,18 +95,21 @@ static const MMRadioRegion_t region_table[] = MM_RADIO_DEEMPHASIS_75_US, // de-emphasis MM_RADIO_FREQ_MIN_87500_KHZ, // min freq. MM_RADIO_FREQ_MAX_108000_KHZ, // max freq. + 50, }, { /* China, Europe, Africa, Middle East, Hong Kong, India, Indonesia, Russia, Singapore */ MM_RADIO_REGION_GROUP_EUROPE, MM_RADIO_DEEMPHASIS_50_US, MM_RADIO_FREQ_MIN_87500_KHZ, MM_RADIO_FREQ_MAX_108000_KHZ, + 50, }, { MM_RADIO_REGION_GROUP_JAPAN, MM_RADIO_DEEMPHASIS_50_US, MM_RADIO_FREQ_MIN_76100_KHZ, MM_RADIO_FREQ_MAX_89900_KHZ, + 50, }, }; /*--------------------------------------------------------------------------- @@ -166,6 +169,7 @@ _mmradio_apply_region(mm_radio_t* radio, MMRadioRegionType region, bool update) radio->region_setting.deemphasis = region_table[index].deemphasis; radio->region_setting.band_min = region_table[index].band_min; radio->region_setting.band_max = region_table[index].band_max; + radio->region_setting.channel_spacing = region_table[index].channel_spacing; } } } @@ -727,29 +731,29 @@ _mmradio_realize_pipeline(mm_radio_t* radio) gst_init (NULL, NULL); radio->pGstreamer_s = g_new0 (mm_radio_gstreamer_s, 1); - radio->pGstreamer_s->pipeline= gst_pipeline_new ("avsysaudio"); + radio->pGstreamer_s->pipeline= gst_pipeline_new ("fmradio"); - radio->pGstreamer_s->avsysaudiosrc= gst_element_factory_make("avsysaudiosrc","fm audio src"); + radio->pGstreamer_s->audiosrc= gst_element_factory_make("pulsesrc","fm audio src"); radio->pGstreamer_s->queue2= gst_element_factory_make("queue2","queue2"); - radio->pGstreamer_s->avsysaudiosink= gst_element_factory_make("pulsesink","audio sink"); + radio->pGstreamer_s->audiosink= gst_element_factory_make("pulsesink","audio sink"); - g_object_set(radio->pGstreamer_s->avsysaudiosrc, "latency", 2, NULL); - g_object_set(radio->pGstreamer_s->avsysaudiosink, "sync", false, NULL); +// g_object_set(radio->pGstreamer_s->audiosrc, "latency", 2, NULL); + g_object_set(radio->pGstreamer_s->audiosink, "sync", false, NULL); - if (!radio->pGstreamer_s->pipeline || !radio->pGstreamer_s->avsysaudiosrc || !radio->pGstreamer_s->queue2 || !radio->pGstreamer_s->avsysaudiosink) { + if (!radio->pGstreamer_s->pipeline || !radio->pGstreamer_s->audiosrc || !radio->pGstreamer_s->queue2 || !radio->pGstreamer_s->audiosink) { debug_error("[%s][%05d] One element could not be created. Exiting.\n", __func__, __LINE__); return MM_ERROR_RADIO_NOT_INITIALIZED; } gst_bin_add_many(GST_BIN(radio->pGstreamer_s->pipeline), - radio->pGstreamer_s->avsysaudiosrc, + radio->pGstreamer_s->audiosrc, radio->pGstreamer_s->queue2, - radio->pGstreamer_s->avsysaudiosink, + radio->pGstreamer_s->audiosink, NULL); if(!gst_element_link_many( - radio->pGstreamer_s->avsysaudiosrc, + radio->pGstreamer_s->audiosrc, radio->pGstreamer_s->queue2, - radio->pGstreamer_s->avsysaudiosink, + radio->pGstreamer_s->audiosink, NULL)) { debug_error("[%s][%05d] Fail to link b/w appsrc and ffmpeg in rotate\n", __func__, __LINE__); return MM_ERROR_RADIO_NOT_INITIALIZED; @@ -1510,3 +1514,19 @@ int _mmradio_get_region_frequency_range(mm_radio_t* radio, unsigned int *min_fre MMRADIO_LOG_FLEAVE(); return MM_ERROR_NONE; } + +int _mmradio_get_channel_spacing(mm_radio_t* radio, unsigned int *ch_spacing) +{ + MMRADIO_LOG_FENTER(); + MMRADIO_CHECK_INSTANCE( radio ); + MMRADIO_CHECK_STATE_RETURN_IF_FAIL( radio, MMRADIO_COMMAND_GET_REGION ); + + return_val_if_fail( ch_spacing, MM_ERROR_INVALID_ARGUMENT ); + + *ch_spacing = radio->region_setting.channel_spacing; + + MMRADIO_LOG_FLEAVE(); + return MM_ERROR_NONE; +} + + diff --git a/test/Makefile.am b/test/Makefile.am index f555611..c640ca4 100755 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -4,9 +4,10 @@ mm_radio_testsuite_SOURCES = mm_radio_testsuite.c \ mm_radio_rt_api_test.c mm_radio_testsuite_CFLAGS = -I$(srcdir)/../src/include \ - $(MMCOMMON_CFLAGS) + $(MMCOMMON_CFLAGS) \ + -fPIC -pie + +mm_radio_testsuite_DEPENDENCIES = $(top_builddir)/src/libmmfradio.la -mm_radio_testsuite_DEPENDENCIES = $(top_builddir)/src/libmmfradio.la - mm_radio_testsuite_LDADD = $(top_builddir)/src/libmmfradio.la \ $(MMCOMMON_LIBS) diff --git a/test/mm_radio_rt_api_test.c b/test/mm_radio_rt_api_test.c index 6a881ff..1b1224f 100755 --- a/test/mm_radio_rt_api_test.c +++ b/test/mm_radio_rt_api_test.c @@ -23,7 +23,7 @@ #include "mm_radio.h" #include "mm_radio_rt_api_test.h" -#define MENU_ITEM_MAX 19 +#define MENU_ITEM_MAX 20 #define _MAX_INPUT_STRING_ 100 static int __menu(void); @@ -160,6 +160,15 @@ void __call_api( int choosen ) RADIO_TEST__( mm_radio_get_signal_strength(g_my_radio, &signal_strength); ) printf("signal strength is : %d \n", signal_strength); } + break; + case 20: + { + int channel_spacing = 0; + RADIO_TEST__( mm_radio_get_channel_spacing(g_my_radio, &channel_spacing); ) + printf("channel_spacing is : %d \n", channel_spacing); + } + break; + default: break; } @@ -210,10 +219,11 @@ int __menu(void) printf("[17] mm_radio_get_region_type\n"); printf("[18] mm_radio_get_region_frequency_range\n"); printf("[19] mm_radio_signal_strength\n"); + printf("[20] mm_radio_get_channel_spacing\n"); printf("[0] quit\n"); printf("---------------------------------------------------------\n"); printf("choose one : "); - + if ( scanf("%d", &menu_item) == 0) { char temp[_MAX_INPUT_STRING_];