Fixed Music Player Reacquisition when image is captured 30/61530/1 accepted/tizen/mobile/20160310.063453 submit/tizen_mobile/20160309.124026
authorbhutani.92 <bhutani.92@samsung.com>
Tue, 8 Mar 2016 12:28:27 +0000 (17:58 +0530)
committerbhutani.92 <bhutani.92@samsung.com>
Tue, 8 Mar 2016 12:28:27 +0000 (17:58 +0530)
Change-Id: Ia55b65ecbccd5046d3631a040d0de7e24088b146
Signed-off-by: bhutani.92 <bhutani.92@samsung.com>
src/core/mp-player-control.c
src/core/mp-player-mgr.c

index e578126..9dcd83f 100755 (executable)
@@ -284,7 +284,7 @@ _mp_play_control_interrupted_cb(player_interrupted_code_e code, void *userdata)
                break;
        }
 
-       /* if playback interrupted while seeking, seek complete callback will not be ivoked. */
+       /* if playback interrupted while seeking, seek complete callback will not be invoked. */
        mp_player_mgr_seek_done(ad);
 
        ad->paused_by_user = true;
index 0353488..eb6be44 100755 (executable)
@@ -17,6 +17,7 @@
 
 
 #include <glib.h>
+#include <string.h>
 #include "music.h"
 #include "mp-player-mgr.h"
 #include "mp-player-control.h"
@@ -783,14 +784,16 @@ mp_player_mgr_play(void *data)
        }
 
        PLAYER_ENTER_LOG("start");
-       error = sound_manager_acquire_focus(ad->stream_info, SOUND_STREAM_FOCUS_FOR_PLAYBACK, NULL);
-       if (error != SOUND_MANAGER_ERROR_NONE) {
-               ERROR_TRACE("failed to acquire focus [%x]", error);
-       }
+       if (ad->stream_info) {
+               error = sound_manager_acquire_focus(ad->stream_info, SOUND_STREAM_FOCUS_FOR_PLAYBACK, NULL);
+               if (error != SOUND_MANAGER_ERROR_NONE) {
+                       ERROR_TRACE("failed to acquire focus [%x]", error);
+               }
 
-       sound_manager_get_focus_reacquisition(ad->stream_info, &reacquire_state);
-       if (reacquire_state == EINA_FALSE) {
-               sound_manager_set_focus_reacquisition(ad->stream_info, EINA_TRUE);
+               sound_manager_get_focus_reacquisition(ad->stream_info, &reacquire_state);
+               if (reacquire_state == EINA_FALSE) {
+                       sound_manager_set_focus_reacquisition(ad->stream_info, EINA_TRUE);
+               }
        }
        err = g_player_apis.start(_player);
        PLAYER_LEAVE_LOG("start");
@@ -859,8 +862,6 @@ mp_player_mgr_resume(void *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(ad->stream_info, &state_for_playback,
-                                                                               &state_for_recording);
 
        mp_util_lock_cpu();
        if (!mp_player_mgr_is_active()) {
@@ -871,18 +872,23 @@ mp_player_mgr_resume(void *data)
                        return err;
                }
        }
-        if (state_for_playback != SOUND_STREAM_FOCUS_STATE_ACQUIRED) {
-               error = sound_manager_acquire_focus(ad->stream_info, SOUND_STREAM_FOCUS_FOR_PLAYBACK, NULL);
-               if (error != SOUND_MANAGER_ERROR_NONE) {
-                       ERROR_TRACE("failed to acquire focus [%x]", error);
-                       return error;
-               }
-       }
 
-       sound_manager_get_focus_reacquisition(ad->stream_info, &reacquire_state);
-       if (reacquire_state == EINA_FALSE) {
-               sound_manager_set_focus_reacquisition(ad->stream_info, EINA_TRUE);
+       if (ad->stream_info) {
+               ret = sound_manager_get_focus_state(ad->stream_info, &state_for_playback, &state_for_recording);
+               if (state_for_playback != SOUND_STREAM_FOCUS_STATE_ACQUIRED) {
+                       error = sound_manager_acquire_focus(ad->stream_info, SOUND_STREAM_FOCUS_FOR_PLAYBACK, NULL);
+                       if (error != SOUND_MANAGER_ERROR_NONE) {
+                               ERROR_TRACE("failed to acquire focus [%x]", error);
+                               return error;
+                       }
+               }
+
+               sound_manager_get_focus_reacquisition(ad->stream_info, &reacquire_state);
+               if (reacquire_state == EINA_FALSE) {
+                       sound_manager_set_focus_reacquisition(ad->stream_info, EINA_TRUE);
+               }
        }
+
        if (mp_player_mgr_get_state() != PLAYER_STATE_IDLE) {
                DEBUG_TRACE("player state is ready");
                PLAYER_ENTER_LOG("start");
@@ -925,9 +931,11 @@ mp_player_mgr_pause(void *data)
 
        PLAYER_ENTER_LOG("pause");
        err = g_player_apis.pause(_player);
-       error = sound_manager_release_focus(ad->stream_info, SOUND_STREAM_FOCUS_FOR_PLAYBACK, NULL);
-       if (error != SOUND_MANAGER_ERROR_NONE) {
-               ERROR_TRACE("failed to release focus error[%x]", error);
+       if (ad->stream_info) {
+               error = sound_manager_release_focus(ad->stream_info, SOUND_STREAM_FOCUS_FOR_PLAYBACK, NULL);
+               if (error != SOUND_MANAGER_ERROR_NONE) {
+                       ERROR_TRACE("failed to release focus error[%x]", error);
+               }
        }
        PLAYER_LEAVE_LOG("pause");
 
@@ -1150,7 +1158,9 @@ void mp_player_focus_callback(sound_stream_info_h stream_info, sound_stream_focu
                if (reason_for_change != SOUND_STREAM_FOCUS_CHANGED_BY_ALARM &&
                                reason_for_change != SOUND_STREAM_FOCUS_CHANGED_BY_NOTIFICATION) {
                        sound_manager_get_focus_reacquisition(ad->stream_info, &reacquire_state);
-                       if (reacquire_state == EINA_TRUE) {
+                       if (!strcmp(additional_info, "cam_capture")) {
+                               sound_manager_set_focus_reacquisition(ad->stream_info, EINA_TRUE);
+                       } else if (reacquire_state == EINA_TRUE) {
                                sound_manager_set_focus_reacquisition(ad->stream_info, EINA_FALSE);
                        }
                }