From e86abb290e524c4e605eeec559118bbd70b305ff Mon Sep 17 00:00:00 2001 From: "bhutani.92" Date: Tue, 8 Mar 2016 17:58:27 +0530 Subject: [PATCH] Fixed Music Player Reacquisition when image is captured Change-Id: Ia55b65ecbccd5046d3631a040d0de7e24088b146 Signed-off-by: bhutani.92 --- src/core/mp-player-control.c | 2 +- src/core/mp-player-mgr.c | 56 ++++++++++++++++++++++++++------------------ 2 files changed, 34 insertions(+), 24 deletions(-) diff --git a/src/core/mp-player-control.c b/src/core/mp-player-control.c index e578126..9dcd83f 100755 --- a/src/core/mp-player-control.c +++ b/src/core/mp-player-control.c @@ -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; diff --git a/src/core/mp-player-mgr.c b/src/core/mp-player-mgr.c index 0353488..eb6be44 100755 --- a/src/core/mp-player-mgr.c +++ b/src/core/mp-player-mgr.c @@ -17,6 +17,7 @@ #include +#include #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); } } -- 2.7.4