From e625ed1189734c5e9b19796c5c8c4274b1fa82e3 Mon Sep 17 00:00:00 2001 From: Sangchul Lee Date: Tue, 14 Mar 2017 12:53:18 +0900 Subject: [PATCH] [0.6.35] update internal focus status right after acquring/releasing focus Modification for session backward compatibility. Change-Id: Ia8dae00d1fb042884a9bd2c657e7ece7575a615f --- packaging/libmm-player.spec | 2 +- src/mm_player_priv.c | 16 +++++++++------- src/mm_player_sound_focus.c | 23 ++++++++++------------- 3 files changed, 20 insertions(+), 21 deletions(-) diff --git a/packaging/libmm-player.spec b/packaging/libmm-player.spec index a504516..11aed47 100644 --- a/packaging/libmm-player.spec +++ b/packaging/libmm-player.spec @@ -1,6 +1,6 @@ Name: libmm-player Summary: Multimedia Framework Player Library -Version: 0.6.34 +Version: 0.6.35 Release: 0 Group: Multimedia/Libraries License: Apache-2.0 diff --git a/src/mm_player_priv.c b/src/mm_player_priv.c index 6ded73d..bc7bd18 100644 --- a/src/mm_player_priv.c +++ b/src/mm_player_priv.c @@ -4539,7 +4539,6 @@ void __mmplayer_gst_set_audiosink_property(mm_player_t* player, MMHandleType att gint stream_id = 0; gchar stream_props[MAX_PROPS_LEN] = {0,}; GstStructure *props = NULL; - gint stream_focus_status = 0; /* set volume table * It should be set after player creation through attribute. @@ -4552,14 +4551,15 @@ void __mmplayer_gst_set_audiosink_property(mm_player_t* player, MMHandleType att if (!stream_type) { LOGE("stream_type is null.\n"); } else { - if (_mmplayer_is_using_internal_sound_focus(&player->sound_focus)) - stream_focus_status = 1; - - snprintf(stream_props, sizeof(stream_props)-1, "props,media.role=%s, media.parent_id=%d, media.focus_status=%d", - stream_type, stream_id, stream_focus_status); + if (player->sound_focus.focus_id) + snprintf(stream_props, sizeof(stream_props)-1, "props,media.role=%s, media.parent_id=%d, media.focus_id=%d", + stream_type, stream_id, player->sound_focus.focus_id); + else + snprintf(stream_props, sizeof(stream_props)-1, "props,media.role=%s, media.parent_id=%d", + stream_type, stream_id); props = gst_structure_from_string(stream_props, NULL); g_object_set(player->pipeline->audiobin[MMPLAYER_A_SINK].gst, "stream-properties", props, NULL); - LOGI("stream_id[%d], stream_type[%s], stream_focus[%d], result[%s].\n", stream_id, stream_type, stream_focus_status, stream_props); + LOGI("stream_type[%s], stream_id[%d], focus_id[%d], result[%s].\n", stream_type, stream_id, player->sound_focus.focus_id, stream_props); } mm_attrs_get_int_by_name(attrs, "sound_latency_mode", &latency_mode); @@ -8389,6 +8389,8 @@ DONE: player->sound_focus.cb_pending = FALSE; EXIT: + if (mm_sound_update_focus_status(id, 0)) + LOGE("failed to update focus status\n"); MMPLAYER_CMD_UNLOCK(player); LOGW("dispatched"); return; diff --git a/src/mm_player_sound_focus.c b/src/mm_player_sound_focus.c index a36fb13..d38414c 100644 --- a/src/mm_player_sound_focus.c +++ b/src/mm_player_sound_focus.c @@ -121,7 +121,6 @@ int _mmplayer_sound_acquire_focus(MMPlayerSoundFocus* sound_focus) { int ret = MM_ERROR_NONE; - const gchar *stream_type = NULL; MMPLAYER_FENTER(); MMPLAYER_CHECK_SOUND_FOCUS_INSTANCE(sound_focus); @@ -131,10 +130,7 @@ _mmplayer_sound_acquire_focus(MMPlayerSoundFocus* sound_focus) return MM_ERROR_NONE; } - stream_type = __mmplayer_sound_get_stream_type(sound_focus->session_type); - - if ((!strstr(stream_type, "media")) || - (sound_focus->session_flags & MM_SESSION_OPTION_PAUSE_OTHERS)) { + if (_mmplayer_is_using_internal_sound_focus(sound_focus)) { ret = mm_sound_acquire_focus(sound_focus->focus_id, FOCUS_FOR_BOTH, NULL); if (ret != MM_ERROR_NONE) { @@ -143,6 +139,10 @@ _mmplayer_sound_acquire_focus(MMPlayerSoundFocus* sound_focus) } sound_focus->acquired = TRUE; + + ret = mm_sound_update_focus_status(sound_focus->focus_id, 1); + if (ret != MM_ERROR_NONE) + LOGE("failed to update focus status\n"); } MMPLAYER_FLEAVE(); @@ -153,7 +153,6 @@ int _mmplayer_sound_release_focus(MMPlayerSoundFocus* sound_focus) { int ret = MM_ERROR_NONE; - const gchar *stream_type = NULL; MMPLAYER_FENTER(); MMPLAYER_CHECK_SOUND_FOCUS_INSTANCE(sound_focus); @@ -163,10 +162,7 @@ _mmplayer_sound_release_focus(MMPlayerSoundFocus* sound_focus) return MM_ERROR_NONE; } - stream_type = __mmplayer_sound_get_stream_type(sound_focus->session_type); - - if ((!strstr(stream_type, "media")) || - (sound_focus->session_flags & MM_SESSION_OPTION_PAUSE_OTHERS)) { + if (_mmplayer_is_using_internal_sound_focus(sound_focus)) { ret = mm_sound_release_focus(sound_focus->focus_id, FOCUS_FOR_BOTH, NULL); if (ret != MM_ERROR_NONE) { LOGE("failed to release sound focus\n"); @@ -174,6 +170,10 @@ _mmplayer_sound_release_focus(MMPlayerSoundFocus* sound_focus) } sound_focus->acquired = FALSE; + + ret = mm_sound_update_focus_status(sound_focus->focus_id, 0); + if (ret != MM_ERROR_NONE) + LOGE("failed to update focus status\n"); } MMPLAYER_FLEAVE(); @@ -354,9 +354,6 @@ bool _mmplayer_is_using_internal_sound_focus(MMPlayerSoundFocus* sound_focus) return false; if ((sound_focus->session_type == MM_SESSION_TYPE_MEDIA && sound_focus->session_flags & MM_SESSION_OPTION_PAUSE_OTHERS) || - (sound_focus->session_type == MM_SESSION_TYPE_CALL) || - (sound_focus->session_type == MM_SESSION_TYPE_VIDEOCALL) || - (sound_focus->session_type == MM_SESSION_TYPE_VOIP) || (sound_focus->session_type == MM_SESSION_TYPE_NOTIFY) || (sound_focus->session_type == MM_SESSION_TYPE_ALARM) || (sound_focus->session_type == MM_SESSION_TYPE_EMERGENCY)) -- 2.7.4