Add radio set/get volume code 10/96710/1 accepted/tizen/3.0/common/20161116.144044 accepted/tizen/3.0/ivi/20161116.023423 accepted/tizen/3.0/mobile/20161116.022911 accepted/tizen/3.0/wearable/20161116.023319 submit/tizen_3.0/20161115.060306
authorGilbok Lee <gilbok.lee@samsung.com>
Thu, 10 Nov 2016 02:30:20 +0000 (11:30 +0900)
committerGilbok Lee <gilbok.lee@samsung.com>
Thu, 10 Nov 2016 02:30:49 +0000 (11:30 +0900)
[Version] 0.1.6
[Profile] Mobile, Wearable
[Issue Type] Add features

Change-Id: Id6630623bf6ad144188d6dcffa275c791e07d25a

include/radio.h
packaging/capi-media-radio.spec
src/radio.c
test/radio_test.c

index 1f5a84365348eb87cc83ee8f1d464ceebcddcd63..ce4a957cbfc5721eb6b3b30314ee1929c155c761 100755 (executable)
@@ -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);
 
 /**
  * @}
index 5f9d909cd1591146710306d31360396c8fdc52a7..8df2374951aedc7e40c433d11b9436ac1523bb1f 100644 (file)
@@ -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
index 6684f1b7245ef883d439e7f8c799c2911674b625..5fd19f3aba1ba4f68288c9123cbdc8df6d46f420 100644 (file)
@@ -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;
+       }
+}
+
index 82f1654b6e687baaf72da0f231edf9eef021a288..a8a11fedf799fc243732c04ed044d9227649b467 100755 (executable)
@@ -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);