Fixed: MediaPlayer focus for call reason. 43/101243/2
authorDenis Dolzhenko <d.dolzhenko@samsung.com>
Wed, 30 Nov 2016 12:27:13 +0000 (14:27 +0200)
committerDenis Dolzhenko <d.dolzhenko@samsung.com>
Wed, 30 Nov 2016 14:03:26 +0000 (16:03 +0200)
Change-Id: Ia8a1fc985325c52593cf8eb5d610fc6535018959
Signed-off-by: Denis Dolzhenko <d.dolzhenko@samsung.com>
src/Viewer/Utils/inc/MediaPlayer.h
src/Viewer/Utils/src/MediaPlayer.cpp

index 60d0d66bc4fcf023f2f794608f927ffc8a308692..9dbd8b2933645746d5e0a728bc7b60141f984628 100644 (file)
@@ -56,6 +56,7 @@ namespace Msg
                                                                const char *extra_info,
                                                                void *user_data);
             player_state_e getState() const;
+            static bool isCallReason(sound_stream_focus_change_reason_e reason);
 
         private:
             player_h m_Player;
index 2aaf31f9a3b058f562e63729e3ce50a1017bcff3..924354229a76b85f7f78fd0f19d45ef2e6bf61cc 100644 (file)
@@ -71,6 +71,13 @@ player_state_e MediaPlayer::getState() const
     return state;
 }
 
+bool MediaPlayer::isCallReason(sound_stream_focus_change_reason_e reason)
+{
+    return reason == SOUND_STREAM_FOCUS_CHANGED_BY_RINGTONE ||
+           reason == SOUND_STREAM_FOCUS_CHANGED_BY_VOIP ||
+           reason == SOUND_STREAM_FOCUS_CHANGED_BY_CALL;
+}
+
 bool MediaPlayer::getFocus() const
 {
     sound_stream_focus_change_reason_e acquiredBy = SOUND_STREAM_FOCUS_CHANGED_BY_MEDIA;
@@ -80,9 +87,7 @@ bool MediaPlayer::getFocus() const
     if (sound_manager_get_current_playback_focus(&acquiredBy, &flags, &extraInfo) == SOUND_MANAGER_ERROR_NONE)
     {
         free(extraInfo);
-        return acquiredBy != SOUND_STREAM_FOCUS_CHANGED_BY_RINGTONE &&
-               acquiredBy != SOUND_STREAM_FOCUS_CHANGED_BY_VOIP &&
-               acquiredBy != SOUND_STREAM_FOCUS_CHANGED_BY_CALL;
+        return !isCallReason(acquiredBy);
     }
 
     return true;
@@ -180,8 +185,9 @@ void MediaPlayer::on_sound_stream_focus_state_changed_cb(sound_stream_info_h str
 {
     MSG_LOG("Interrupted focus change reason = ", reason);
     auto *self = static_cast<MediaPlayer*>(user_data);
-    ecore_main_loop_thread_safe_call_async
-    (
+    if (isCallReason(reason))
+    {
+        ecore_main_loop_thread_safe_call_async(
         [](void *data)
         {
             auto *self = (MediaPlayer*)data;
@@ -189,4 +195,5 @@ void MediaPlayer::on_sound_stream_focus_state_changed_cb(sound_stream_info_h str
                 self->m_pListener->onMediaPlayerSoundFocusChanged();
         },
         self);
+    }
 }