[TSAM-1052]Resolved crash issue in music player 87/59787/2 accepted/tizen/mobile/20160223.232838 submit/tizen_mobile/20160223.121458
authorShubham Kumar <shubham.srib@samsung.com>
Thu, 18 Feb 2016 12:03:49 +0000 (17:33 +0530)
committerShubham Kumar <shubham.srib@samsung.com>
Tue, 23 Feb 2016 05:26:26 +0000 (10:56 +0530)
Change-Id: I943eddf9f0799e449ccfe208cdb9ebb513124015
Signed-off-by: Shubham Kumar <shubham.srib@samsung.com>
src/core/mp-player-mgr.c

index c32083a944fa1a6577f7cb77db9469834f2cc9bc..c66af45056961d41d0a7c966a9aa407c7b238f28 100755 (executable)
@@ -860,6 +860,11 @@ mp_player_mgr_resume(void *data)
        struct appdata *ad = data;
        MP_CHECK_FALSE(ad);
        int err = -1,error = -1;
+       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()) {
@@ -870,10 +875,12 @@ mp_player_mgr_resume(void *data)
                        return err;
                }
        }
-
-       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 (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);
@@ -1152,7 +1159,7 @@ void mp_player_focus_callback(sound_stream_info_h stream_info, sound_stream_focu
                        }
                }
        } else {
-               ret = mp_player_mgr_play(ad);
+               mp_play_control_play_pause(ad, true);
        }
 }