[TSAM-756]depricated sound-manager API's removed from video-player 01/59001/3
authorShubham Kumar <shubham.srib@samsung.com>
Mon, 8 Feb 2016 05:52:39 +0000 (11:22 +0530)
committerShubham Kumar <shubham.srib@samsung.com>
Mon, 8 Feb 2016 06:02:21 +0000 (11:32 +0530)
Change-Id: Ibc00821e0293586766179e208c637c0032c9e332
Signed-off-by: Shubham Kumar <shubham.srib@samsung.com>
playview/src/core/vp-mm-player.c
playview/src/core/vp-sound.c
playview/src/view/include/vp-play-view-priv.h
playview/src/view/vp-play-normal-view.c
playview/src/vp-play-view.c

index e8e4a839d7961b3afdf78af4d4f51f9f5dfa6cf1..ab7db1b856edb1a687fea63aa09dbd43375d9643 100644 (file)
@@ -237,23 +237,8 @@ static int _vp_mm_player_priv_convert_interrupt(int nCode, bool bAppToFW)
 
        if (bAppToFW) {
                switch (nCode) {
-               case PLAYER_INTERRUPTED_COMPLETED:
-                       return VP_MM_PLAYER_INTERRUPTED_COMPLETED;
-               case PLAYER_INTERRUPTED_BY_MEDIA:
-                       return VP_MM_PLAYER_INTERRUPTED_BY_MEDIA;
-               case PLAYER_INTERRUPTED_BY_CALL:
-                       return VP_MM_PLAYER_INTERRUPTED_BY_CALL;
-               case PLAYER_INTERRUPTED_BY_EARJACK_UNPLUG:
-                       return VP_MM_PLAYER_INTERRUPTED_BY_EARJACK_UNPLUG;
-               case PLAYER_INTERRUPTED_BY_RESOURCE_CONFLICT:
+                case PLAYER_INTERRUPTED_BY_RESOURCE_CONFLICT:
                        return VP_MM_PLAYER_INTERRUPTED_BY_RESOURCE_CONFLICT;
-               case PLAYER_INTERRUPTED_BY_ALARM:
-                       return VP_MM_PLAYER_INTERRUPTED_BY_ALARM;
-               case PLAYER_INTERRUPTED_BY_EMERGENCY:
-                       return VP_MM_PLAYER_INTERRUPTED_BY_EMERGENCY;
-                       //case PLAYER_INTERRUPTED_BY_RESUMABLE_MEDIA:   return VP_MM_PLAYER_INTERRUPTED_RESUMABLE_MEDIA;
-               case PLAYER_INTERRUPTED_BY_NOTIFICATION:
-                       return VP_MM_PLAYER_INTERRUPTED_NOTIFICATION;
                }
        } else {
                switch (nCode) {
@@ -1238,7 +1223,6 @@ mm_player_handle vp_mm_player_create()
 {
        MMPlayer *pMMPlayer = NULL;
        pMMPlayer = calloc(1, sizeof(MMPlayer));
-
        if (pMMPlayer == NULL) {
                VideoLogError("MMPlayer alloc fail");
                return NULL;
@@ -1259,12 +1243,6 @@ mm_player_handle vp_mm_player_create()
                vp_mm_player_destroy((mm_player_handle) pMMPlayer);
                return NULL;
        }
-
-
-       nRet = player_set_sound_type(pMMPlayer->pPlayer, SOUND_TYPE_MEDIA);
-       if (nRet != PLAYER_ERROR_NONE) {
-               _vp_mm_player_print_err(nRet);
-       }
 //      nRet = player_set_rich_audio(pMMPlayer->pPlayer);
 //      if (nRet != PLAYER_ERROR_NONE) {
 //              _vp_mm_player_print_err(nRet);
index 68d04f8f6dc307a762e10576ceb3b5e8a4116b3c..f08e31cbe448ba8b8e84c62a1e3b793f6be4b13a 100644 (file)
@@ -18,6 +18,7 @@
 #include <sound_manager.h>
 #include "vp-play-macro-define.h"
 #include "vp-play-normal-view.h"
+#include "vp-play-view.h"
 #include "vp-sound.h"
 
 /* check temp */
 /* internal functions */
 
 /* external functions */
-bool vp_sound_init_session()
+
+void vp_player_focus_callback(sound_stream_info_h stream_info, sound_stream_focus_change_reason_e reason_for_change,
+                                       const char *additional_info, void *user_data)
+{
+       PlayView *pPlayView = (PlayView *)user_data;
+
+       sound_stream_focus_state_e state_for_playback;
+       sound_stream_focus_state_e state_for_recording;
+       int ret = -1;
+       ret = sound_manager_get_focus_state(pPlayView->stream_info, &state_for_playback,
+                                                                               &state_for_recording);
+       if (state_for_playback == SOUND_STREAM_FOCUS_STATE_RELEASED) {
+               vp_play_view_unrealize(pPlayView);
+
+               if (reason_for_change != SOUND_STREAM_FOCUS_CHANGED_BY_ALARM &&
+                               reason_for_change != SOUND_STREAM_FOCUS_CHANGED_BY_NOTIFICATION) {
+                       sound_manager_get_focus_reacquisition(pPlayView->stream_info, &pPlayView->reacquire_state);
+                       if (pPlayView->reacquire_state == EINA_TRUE) {
+                               sound_manager_set_focus_reacquisition(pPlayView->stream_info, EINA_FALSE);
+                       }
+               }
+       } else {
+               ret = vp_play_view_realize(pPlayView);
+       }
+}
+
+bool vp_sound_init_session(play_view_handle pViewHandle)
 {
        VideoLogInfo(">> Sound Session : Init");
 
+        PlayView *pPlayView = (PlayView *)pViewHandle;
        int nRet = SOUND_MANAGER_ERROR_NONE;
-       nRet = sound_manager_set_session_type(SOUND_SESSION_TYPE_MEDIA);
-       if (nRet != SOUND_MANAGER_ERROR_NONE) {
-               VideoLogError("sound_manager_set_session_type fail");
-               return FALSE;
-       }
+       if (!pPlayView->stream_info) {
+               nRet = sound_manager_create_stream_information(SOUND_STREAM_TYPE_MEDIA, vp_player_focus_callback, pPlayView, &pPlayView->stream_info);
 
-       nRet =
-           sound_manager_set_media_session_option
-           (SOUND_SESSION_OPTION_PAUSE_OTHERS_WHEN_START,
-            SOUND_SESSION_OPTION_INTERRUPTIBLE_DURING_PLAY);
-       if (nRet != SOUND_MANAGER_ERROR_NONE) {
-               VideoLogError("sound_manager_set_media_session_option fail");
-               return FALSE;
+               if (nRet != SOUND_MANAGER_ERROR_NONE) {
+                       VideoLogError("failed to create_stream_information %x", nRet);
+                       return FALSE;
+               }
        }
 
        nRet = sound_manager_set_current_sound_type(SOUND_TYPE_MEDIA);
@@ -64,17 +86,17 @@ bool vp_sound_init_session()
        return TRUE;
 }
 
-bool vp_sound_deinit_session()
+bool vp_sound_deinit_session(play_view_handle pViewHandle)
 {
        int nRet = SOUND_MANAGER_ERROR_NONE;
-
+        PlayView *pPlayView = (PlayView *)pViewHandle;
 //      nRet = sound_manager_unset_safety_volume();
 //      if (nRet != SOUND_MANAGER_ERROR_NONE) {
 //              VideoLogError("sound_manager_unset_safety_volume fail");
 //              return FALSE;
 //      }
 
-       nRet = sound_manager_unset_current_sound_type();
+       nRet = sound_manager_destroy_stream_information(pPlayView->stream_info);
        if (nRet != SOUND_MANAGER_ERROR_NONE) {
                VideoLogError("sound_manager_unset_current_sound_type fail");
                return FALSE;
index b8111e8247a4ecf324f1613699850a4592fb0db3..79fa7edafca60045eb3cc23bf097a7f8e402f8ed 100644 (file)
@@ -21,6 +21,7 @@
 #include <stdbool.h>
 #include <Elementary.h>
 #include <net_connection.h>
+#include <sound_manager.h>
 
 #include "vp-play-view.h"
 #include "vp-play-type-define.h"
@@ -125,7 +126,9 @@ typedef struct _PlayView {
        video_play_rotate_t             nRotate;
        video_sound_alive_t             nSoundAlive;
        video_play_list_type_t          nListType;
+       sound_stream_info_h             stream_info;
 
+        bool                            reacquire_state;
        bool                            bPopupMode;
        bool                            bTrimExit;
        bool                            bRelaunchCaller;
index 2b993fb8acfdc1fc2aac792b4ba342ecb489fad6..9a5ba6a0c00066c7e989f23dfba65ae0de575082 100755 (executable)
@@ -17,6 +17,7 @@
 
 
 #include <math.h>
+#include <sound_manager.h>
 #include "vp-play-type-define.h"
 #include "vp-play-string-define.h"
 #include "vp-play-value-define.h"
@@ -6884,6 +6885,11 @@ static bool _vp_play_normal_view_play_start(NormalView *pNormalView, bool bCheck
                VideoLogError("vp_mm_player_create fail");
                return FALSE;
        }
+       int nRet;
+       nRet = player_set_audio_policy_info(pNormalView->pPlayerHandle, pNormalView->pPlayView->stream_info);
+       if (nRet != PLAYER_ERROR_NONE) {
+               VideoLogError("unable to set sound policy [%x]", nRet);
+       }
 
        if (!vp_mm_player_set_user_param(pNormalView->pPlayerHandle, (void *) pNormalView)) {
                VideoLogError("vp_mm_player_set_user_param fail");
index a60c3436c5761b86b3ecc07a3f04e65a7f38ccf6..87daf04076304ec3796dfa963689df8b8d55deeb 100644 (file)
@@ -1889,6 +1889,7 @@ bool vp_play_view_live_stream_realize(play_view_handle pViewHandle)
 
 bool vp_play_view_realize(play_view_handle pViewHandle)
 {
+        int error = SOUND_MANAGER_ERROR_NONE;
        if (!pViewHandle) {
                VideoLogError("PlayView handle is NULL");
                return FALSE;
@@ -1902,6 +1903,15 @@ bool vp_play_view_realize(play_view_handle pViewHandle)
        pPlayView->bVisible = TRUE;
        vp_play_normal_view_key_create(pPlayView, pPlayView->pNormalView);
        vp_play_normal_view_set_share_panel_state(pPlayView->pNormalView);
+       error = sound_manager_acquire_focus(pPlayView->stream_info, SOUND_STREAM_FOCUS_FOR_PLAYBACK, NULL);
+       if (error != SOUND_MANAGER_ERROR_NONE) {
+               VideoLogError("failed to acquire focus [%x]", error);
+       }
+
+       sound_manager_get_focus_reacquisition(pPlayView->stream_info, &pPlayView->reacquire_state);
+       if (pPlayView->reacquire_state == EINA_FALSE) {
+               sound_manager_set_focus_reacquisition(pPlayView->stream_info, EINA_TRUE);
+       }
        if (pPlayView->bRealized == TRUE) {
                VideoLogWarning("Already Realize state");
                return TRUE;
@@ -1918,7 +1928,7 @@ bool vp_play_view_realize(play_view_handle pViewHandle)
 #ifdef OLD_SENSOR_API
        vp_sensor_realize(pPlayView->pSensorHandle);
 #endif
-       vp_sound_init_session();
+       vp_sound_init_session(pViewHandle);
 
        vp_sound_set_route_change_cb(__vp_play_sound_route_change_cb, (void *)pPlayView);
        vp_sound_set_volume_change_cb(__vp_play_sound_volume_change_cb, (void *)pPlayView);
@@ -2012,6 +2022,7 @@ bool vp_play_view_realize(play_view_handle pViewHandle)
 
 bool vp_play_view_unrealize(play_view_handle pViewHandle)
 {
+        int error = SOUND_MANAGER_ERROR_NONE;
        if (!pViewHandle) {
                VideoLogError("PlayView handle is NULL");
                return FALSE;
@@ -2044,6 +2055,10 @@ bool vp_play_view_unrealize(play_view_handle pViewHandle)
                vp_play_util_key_ungrab(pPlayView->pWin, VP_VOLUME_MUTE);
                vp_play_util_key_ungrab(pPlayView->pWin, VP_HOME_KEY);
                sound_manager_unset_current_sound_type();
+               error = sound_manager_release_focus(pPlayView->stream_info, SOUND_STREAM_FOCUS_FOR_PLAYBACK, NULL);
+               if (error != SOUND_MANAGER_ERROR_NONE) {
+               VideoLogError("failed to release focus error[%x]", error);
+               }
                media_key_release();
                int nDuration = 0;
                if (vp_play_normal_view_get_video_duration(pPlayView->pNormalView, &nDuration)) {
@@ -2072,7 +2087,7 @@ bool vp_play_view_unrealize(play_view_handle pViewHandle)
 //     vp_device_display_deinit();
 #endif
 
-       vp_sound_deinit_session();
+       vp_sound_deinit_session(pPlayView);
 
        if (pPlayView->bAVRCP) {
                vp_avrcp_noti_player_state(VP_MM_PLAYER_STATE_STOP);