Add setting focus auto reacquirement api 05/51205/17 accepted/tizen/mobile/20151124.234155 accepted/tizen/tv/20151124.234205 accepted/tizen/wearable/20151124.234219 submit/tizen/20151124.091803 submit/tizen/20151124.092122
authorinhyeok <i_bc.kim@samsung.com>
Thu, 5 Nov 2015 08:04:36 +0000 (17:04 +0900)
committerinhyeok <i_bc.kim@samsung.com>
Tue, 24 Nov 2015 08:40:02 +0000 (17:40 +0900)
[Version] Release 0.3.30
[Profile] Common
[Issue Type] Add feature

Change-Id: Ia76804b6ab55d82d1e2ec322331b3eeea7f86efc
Signed-off-by: inhyeok <i_bc.kim@samsung.com>
include/sound_manager.h
packaging/capi-media-sound-manager.spec
src/sound_manager.c
test/sound_manager_test.c

index a398d5b..0dfc347 100644 (file)
@@ -746,6 +746,41 @@ int sound_manager_release_focus(sound_stream_info_h stream_info, sound_stream_fo
 int sound_manager_get_focus_state(sound_stream_info_h stream_info, sound_stream_focus_state_e *state_for_playback, sound_stream_focus_state_e *state_for_recording);
 
 /**
+ * @brief Sets auto focus reacquisition property.
+ * @since_tizen 3.0
+ * @param[in]  stream_info     The handle of stream information
+ * @param[in]  enable  The auto focus reacquisition property to set : (@c true = enable, @c false = disable)
+ *
+ * @remarks    The focus reacquistion is set as default.
+ *      If you don't want to reacquire the focus you've lost automatically, disable the focus reacqusition setting by using this API and vice versa.
+ *
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #SOUND_MANAGER_ERROR_NONE Success
+ * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @pre Call sound_manager_create_stream_information() before calling this function.
+ * @see sound_manager_create_stream_information()
+ */
+int sound_manager_set_focus_reacquisition(sound_stream_info_h stream_info, bool enable);
+
+/**
+ * @brief Gets auto focus reacquisition property.
+ * @since_tizen 3.0
+ * @param[in]  stream_info     The handle of stream information
+ * @param[out] enabled The value of focus auto reacquisition property : (@c true = enabled, @c false = disabled)
+ *
+ * @remarks    The default value is true.
+ *
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #SOUND_MANAGER_ERROR_NONE Success
+ * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @pre Call sound_manager_create_stream_information() before calling this function.
+ * @see sound_manager_create_stream_information()
+ */
+int sound_manager_get_focus_reacquisition(sound_stream_info_h stream_info, bool *enabled);
+
+/**
  * @brief Gets the sound type of the stream information.
  * @since_tizen 3.0
  * @param[in]  stream_info     The handle of stream information
index c0da76e..1357f1d 100755 (executable)
@@ -1,6 +1,6 @@
 Name:       capi-media-sound-manager
 Summary:    Sound Manager library
-Version:    0.3.29
+Version:    0.3.30
 Release:    0
 Group:      Multimedia/API
 License:    Apache-2.0
index a570905..f5df673 100644 (file)
@@ -276,6 +276,39 @@ int sound_manager_apply_stream_routing(sound_stream_info_h stream_info)
        return _convert_sound_manager_error_code(__func__, ret);
 }
 
+int sound_manager_set_focus_reacquisition(sound_stream_info_h stream_info, bool enable)
+{
+       int ret = MM_ERROR_NONE;
+       sound_stream_info_s *stream_h = (sound_stream_info_s*)stream_info;
+
+       LOGI(">> enter");
+
+       SM_INSTANCE_CHECK(stream_h);
+
+       ret = mm_sound_set_focus_reacquisition(stream_h->index, enable);
+
+       LOGI("<< leave : ret(%p)", ret);
+
+       return _convert_sound_manager_error_code(__func__, ret);
+}
+
+int sound_manager_get_focus_reacquisition(sound_stream_info_h stream_info, bool *enabled)
+{
+       int ret = MM_ERROR_NONE;
+       sound_stream_info_s *stream_h = (sound_stream_info_s*)stream_info;
+
+       LOGI(">> enter");
+
+       SM_INSTANCE_CHECK(stream_h);
+       SM_NULL_ARG_CHECK(enabled);
+
+       ret = mm_sound_get_focus_reacquisition(stream_h->index, enabled);
+
+       LOGI("<< leave : ret(%p)", ret);
+
+       return _convert_sound_manager_error_code(__func__, ret);
+}
+
 int sound_manager_acquire_focus(sound_stream_info_h stream_info, sound_stream_focus_mask_e focus_mask, const char *additional_info)
 {
        int ret = MM_ERROR_NONE;
index b5fa7d5..2ddea3d 100644 (file)
@@ -68,6 +68,8 @@ enum {
        CURRENT_STATUS_DESTROY_STREAM_INFO,
        CURRENT_STATUS_SET_FOCUS_WATCH_CB,
        CURRENT_STATUS_UNSET_FOCUS_WATCH_CB,
+       CURRENT_STATUS_SET_FOCUS_REACQUISITION,
+       CURRENT_STATUS_GET_FOCUS_REACQUISITION,
        CURRENT_STATUS_CREATE_VIRTUAL_STREAM,
        CURRENT_STATUS_START_VIRTUAL_STREAM,
        CURRENT_STATUS_STOP_VIRTUAL_STREAM,
@@ -208,6 +210,10 @@ void _interpret_main_menu(char *cmd)
                g_menu_state = CURRENT_STATUS_SET_FOCUS_WATCH_CB;
        else if (strncmp(cmd, "ufw", 3) == 0)
                g_menu_state = CURRENT_STATUS_UNSET_FOCUS_WATCH_CB;
+       else if (strncmp(cmd, "sfr", 3) == 0)
+               g_menu_state = CURRENT_STATUS_SET_FOCUS_REACQUISITION;
+       else if (strncmp(cmd, "gfr", 3) == 0)
+               g_menu_state = CURRENT_STATUS_GET_FOCUS_REACQUISITION;
        else if (strncmp(cmd, "dsi", 3) == 0)
                g_menu_state = CURRENT_STATUS_DESTROY_STREAM_INFO;
        else if (strncmp(cmd, "vcr", 3) == 0)
@@ -289,6 +295,8 @@ void display_sub_basic()
        g_print("gfs. Get Focus State\n");
        g_print("sfw. Set Focus State Watch CB\t");
        g_print("ufw. Unset Focus State Watch CB\n");
+       g_print("sfr. Set Focus Reacquisition\t");
+       g_print("gfr. Get Focus Reacquisition\n");
        g_print("sso. *Set option for stream routing\n");
        g_print("vcr. *Create VStream\t");
        g_print("vsr. *Start VStream\t");
@@ -390,6 +398,10 @@ static void displaymenu()
                g_print("*** input focus type to watch for (0:playback, 1:recording, 2:both)\n");
        else if (g_menu_state == CURRENT_STATUS_UNSET_FOCUS_WATCH_CB)
                g_print("*** press enter to unset focus state watch cb\n");
+       else if (g_menu_state == CURRENT_STATUS_SET_FOCUS_REACQUISITION)
+               g_print("*** input focus reacquisition property (1:enable, 2:disable)\n");
+       else if (g_menu_state == CURRENT_STATUS_GET_FOCUS_REACQUISITION)
+               g_print("*** press enter to get focus reacquisition property (1:enabled, 2:disabled)\n");
        else if (g_menu_state == CURRENT_STATUS_CREATE_VIRTUAL_STREAM)
                g_print("*** press enter to create virtual stream\n");
        else if (g_menu_state == CURRENT_STATUS_START_VIRTUAL_STREAM)
@@ -1285,6 +1297,41 @@ static void interpret(char *cmd)
                reset_menu_state();
                break;
        }
+       case CURRENT_STATUS_SET_FOCUS_REACQUISITION: {
+               int ret = SOUND_MANAGER_ERROR_NONE;
+               bool enable;
+
+               switch (atoi(cmd)) {
+               case 1: /* enable */
+                       enable = true;
+                       break;
+               case 2: /* disable */
+                       enable = false;
+                       break;
+               default:
+                       enable = true;
+                       break;
+               }
+               ret = sound_manager_set_focus_reacquisition(g_stream_info_h, enable);
+               if (ret)
+                       g_print("fail to sound_manager_set_focus_reacquisition, ret(0x%x)\n", ret);
+               reset_menu_state();
+               break;
+       }
+       case CURRENT_STATUS_GET_FOCUS_REACQUISITION: {
+               int ret = SOUND_MANAGER_ERROR_NONE;
+               bool enabled;
+
+               ret = sound_manager_get_focus_reacquisition(g_stream_info_h, &enabled);
+               if (ret)
+                       g_print("fail to sound_manager_get_focus_reacquisition, ret(0x%x)\n", ret);
+               if (enabled)
+                       g_print("auto focus reacquisition is enabled\n");
+               else
+                       g_print("auto focus reacquisition is disabled\n");
+               reset_menu_state();
+               break;
+       }
        case CURRENT_STATUS_CREATE_VIRTUAL_STREAM: {
                int ret = SOUND_MANAGER_ERROR_NONE;
                if (!g_stream_info_h || g_vstream_h) {