From: Gilbok Lee Date: Thu, 10 Nov 2016 02:30:20 +0000 (+0900) Subject: Add radio set/get volume code X-Git-Tag: submit/tizen_3.0/20161115.060306^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9e5835ef07822e191ed4486ed816931e95dbe35b;p=platform%2Fcore%2Fapi%2Fradio.git Add radio set/get volume code [Version] 0.1.6 [Profile] Mobile, Wearable [Issue Type] Add features Change-Id: Id6630623bf6ad144188d6dcffa275c791e07d25a --- diff --git a/include/radio.h b/include/radio.h index 1f5a843..ce4a957 100755 --- a/include/radio.h +++ b/include/radio.h @@ -71,15 +71,15 @@ typedef enum { * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif */ typedef enum { - RADIO_INTERRUPTED_COMPLETED = 0, /**< Interrupt completed */ - RADIO_INTERRUPTED_BY_MEDIA, /**< Interrupted by a non-resumable media application */ - RADIO_INTERRUPTED_BY_CALL, /**< Interrupted by an incoming call */ - RADIO_INTERRUPTED_BY_EARJACK_UNPLUG, /**< Interrupted by unplugging headphones */ + RADIO_INTERRUPTED_COMPLETED = 0, /**< Interrupt completed (Deprecated since 3.0)*/ + RADIO_INTERRUPTED_BY_MEDIA, /**< Interrupted by a non-resumable media application (Deprecated since 3.0)*/ + RADIO_INTERRUPTED_BY_CALL, /**< Interrupted by an incoming call (Deprecated since 3.0)*/ + RADIO_INTERRUPTED_BY_EARJACK_UNPLUG, /**< Interrupted by unplugging headphones (Deprecated since 3.0)*/ RADIO_INTERRUPTED_BY_RESOURCE_CONFLICT, /**< Interrupted by a resource conflict */ - RADIO_INTERRUPTED_BY_ALARM, /**< Interrupted by an alarm */ - RADIO_INTERRUPTED_BY_EMERGENCY, /**< Interrupted by an emergency */ - RADIO_INTERRUPTED_BY_RESUMABLE_MEDIA, /**< Interrupted by a resumable media application */ - RADIO_INTERRUPTED_BY_NOTIFICATION, /**< Interrupted by a notification */ + RADIO_INTERRUPTED_BY_ALARM, /**< Interrupted by an alarm (Deprecated since 3.0)*/ + RADIO_INTERRUPTED_BY_EMERGENCY, /**< Interrupted by an emergency (Deprecated since 3.0)*/ + RADIO_INTERRUPTED_BY_RESUMABLE_MEDIA, /**< Interrupted by a resumable media application (Deprecated since 3.0)*/ + RADIO_INTERRUPTED_BY_NOTIFICATION, /**< Interrupted by a notification (Deprecated since 3.0)*/ } radio_interrupted_code_e; /** @@ -462,6 +462,42 @@ int radio_get_frequency_range(radio_h radio, int *min_freq, int *max_freq); */ int radio_get_channel_spacing(radio_h radio, int *channel_spacing); +/** + * @brief Sets the radio's volume. + * @details Setting this volume adjusts the radio's instance volume, not the system volume. + * The valid range is from 0 to 1.0, inclusive (1.0 = 100%). Default value is 1.0. + * To change system volume, use the @ref CAPI_MEDIA_SOUND_MANAGER_MODULE API. + * Finally, it does not support to set other value into each channel currently. + * @since_tizen 3.0 + * @param[in] radio The handle to radio + * @param[in] volume The volume to set [0.0 ~ 1.0](1.0 = 100%) + * @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 + * @retval #RADIO_ERROR_NOT_SUPPORTED Not supported + * @see radio_get_volume() + */ +int radio_set_volume(radio_h radio, float volume); + +/** + * @brief Gets the radio's current volume. + * @details The range of @a volume is from @c 0 to @c 1.0, inclusive (1.0 = 100%). + * This function gets the radio volume, not the system volume. + * To get the system volume, use the @ref CAPI_MEDIA_SOUND_MANAGER_MODULE API. + * @since_tizen 3.0 + * @param[in] radio The handle to radio + * @param[out] volume The current volume [0.0 ~ 1.0](1.0 = 100%) + * @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 + * @retval #RADIO_ERROR_NOT_SUPPORTED Not supported + * @see radio_set_volume() + */ +int radio_get_volume(radio_h radio, float *volume); /** * @} diff --git a/packaging/capi-media-radio.spec b/packaging/capi-media-radio.spec index 5f9d909..8df2374 100644 --- a/packaging/capi-media-radio.spec +++ b/packaging/capi-media-radio.spec @@ -1,6 +1,6 @@ Name: capi-media-radio Summary: A Radio library in Tizen Native API -Version: 0.1.3 +Version: 0.1.6 Release: 1 Group: API/C API License: Apache-2.0 diff --git a/src/radio.c b/src/radio.c index 6684f1b..5fd19f3 100644 --- a/src/radio.c +++ b/src/radio.c @@ -604,3 +604,40 @@ int radio_get_channel_spacing(radio_h radio, int *channel_spacing) else return RADIO_ERROR_NONE; } + +int radio_set_volume(radio_h radio, float volume) +{ + LOGI("[%s] Enter", __func__); + RADIO_SUPPORT_CHECK(__radio_check_system_info_feature_supported()); + RADIO_INSTANCE_CHECK(radio); + if (volume < 0.0 || volume > 1.0) { + LOGE("[%s] RADIO_ERROR_INVALID_PARAMETER(0x%08x) : Out of range (0.0 ~ 1.0)", __FUNCTION__, RADIO_ERROR_INVALID_PARAMETER); + return RADIO_ERROR_INVALID_PARAMETER; + } + float vol = volume; + radio_s *handle = (radio_s *)radio; + int ret = mm_radio_set_volume(handle->mm_handle, vol); + if (ret != MM_ERROR_NONE) + return __convert_error_code(ret, (char *)__FUNCTION__); + else + return RADIO_ERROR_NONE; +} + +int radio_get_volume(radio_h radio, float *volume) +{ + LOGI("[%s] Enter", __func__); + RADIO_SUPPORT_CHECK(__radio_check_system_info_feature_supported()); + RADIO_INSTANCE_CHECK(radio); + RADIO_NULL_ARG_CHECK(volume); + radio_s *handle = (radio_s *)radio; + + float vol; + int ret = mm_radio_get_volume(handle->mm_handle, &vol); + if (ret != MM_ERROR_NONE) { + return __convert_error_code(ret, (char *)__FUNCTION__); + } else { + *volume = vol; + return RADIO_ERROR_NONE; + } +} + diff --git a/test/radio_test.c b/test/radio_test.c index 82f1654..a8a11fe 100755 --- a/test/radio_test.c +++ b/test/radio_test.c @@ -35,7 +35,8 @@ enum { CURRENT_STATUS_MAINMENU, CURRENT_STATUS_CALL_API, CURRENT_STATUS_SET_FREQ, - CURRENT_STATUS_SET_MUTE + CURRENT_STATUS_SET_MUTE, + CURRENT_STATUS_SET_VOL, }; int g_menu_state = CURRENT_STATUS_MAINMENU; @@ -58,15 +59,13 @@ void __radio_set_interrupted_cb(radio_interrupted_code_e code, void *user_param) int g_num_of_tests = 0; static radio_h g_my_radio = 0; - - - +GMainLoop *loop = NULL; static void display_sub_basic() { g_print("\n"); g_print("=============================================================\n"); - g_print(" FMRadio testing menu\n"); + g_print(" FMRadio testing menu\n"); g_print("-------------------------------------------------------------\n"); g_print(" 1. init test\n"); g_print(" 2. listening gorelra\n"); @@ -93,7 +92,7 @@ static void displaymenu(void) g_print("[4] radio_start\t\t"); g_print("[5] radio_stop\n"); g_print("[6] radio_seek_up\t"); - g_print("[7] radio_seek_dow\n"); + g_print("[7] radio_seek_down\n"); g_print("[8] radio_set_frequency\t"); g_print("[9] radio_get_frequency\n"); g_print("[10] radio_scan_start\t"); @@ -106,7 +105,9 @@ static void displaymenu(void) g_print("[17] radio_unset_interrupted_cb\n"); g_print("[18] radio_get_frequency_range\t\t"); g_print("[19] radio_get_channel_spacing\n"); - g_print("[20] radio_signal_strength\t\t"); + g_print("[20] radio_signal_strength\n"); + g_print("[21] radio_set_volume\t"); + g_print("[22] radio_get_volume\t"); g_print("[0] quit\n"); g_print("---------------------------------------------------------------------------\n"); g_print("choose one : "); @@ -114,6 +115,8 @@ static void displaymenu(void) g_print("input freq : "); } else if (g_menu_state == CURRENT_STATUS_SET_MUTE) { g_print("select one(0:UNMUTE/1:MUTE) : "); + } else if (g_menu_state == CURRENT_STATUS_SET_VOL) { + g_print("input volume (0.0 ~ 1.0) : "); } else { g_print("*** unknown status.\n"); /* exit(0); */ @@ -212,7 +215,7 @@ static void interpret(char *cmd) RADIO_TEST__(radio_set_interrupted_cb(g_my_radio, &__radio_set_interrupted_cb, NULL);) } else if (strncmp(cmd, "17", len) == 0) { RADIO_TEST__(radio_unset_interrupted_cb(g_my_radio);) - } else if (strncmp(cmd, "15", len) == 0) { + } else if (strncmp(cmd, "18", len) == 0) { int min = 0; int max = 0; RADIO_TEST__(radio_get_frequency_range(g_my_radio, &min, &max);) @@ -225,6 +228,12 @@ static void interpret(char *cmd) int signal_strength = 0; RADIO_TEST__(radio_get_signal_strength(g_my_radio, &signal_strength);) g_print("signal strength is : %d \n", signal_strength); + } else if (strncmp(cmd, "21", len) == 0) { + g_menu_state = CURRENT_STATUS_SET_VOL; + } else if (strncmp(cmd, "22", len) == 0) { + float vol = 0.0; + RADIO_TEST__(radio_get_volume(g_my_radio, &vol);) + g_print("volume : %f\n", vol); } else { g_print("UNKNOW COMMAND\n"); } @@ -245,8 +254,14 @@ static void interpret(char *cmd) g_menu_state = CURRENT_STATUS_CALL_API; break; } + case CURRENT_STATUS_SET_VOL: { + float vol = atof(cmd); + RADIO_TEST__(radio_set_volume(g_my_radio, vol);) + g_menu_state = CURRENT_STATUS_CALL_API; + break; + } default: - break; + break; } g_timeout_add(100, timeout_menu_display, 0); } @@ -373,7 +388,7 @@ gboolean input(GIOChannel *channel) int main(int argc, char *argv[]) { GIOChannel *stdin_channel; - GMainLoop *loop = g_main_loop_new(NULL, 0); + loop = g_main_loop_new(NULL, 0); stdin_channel = g_io_channel_unix_new(0); g_io_channel_set_flags(stdin_channel, G_IO_FLAG_NONBLOCK, NULL); g_io_add_watch(stdin_channel, G_IO_IN, (GIOFunc) input, NULL);