From 5d8b8052af3551b80ee4d5089e07b9945cf05620 Mon Sep 17 00:00:00 2001 From: Eunhye Choi Date: Wed, 3 Apr 2019 16:51:34 +0900 Subject: [PATCH] [0.6.178] rebuild pipeline for offload - audio offload could be supportable or not if the audio device type is changed. Change-Id: I836bf19ff510dbd58b32c8fe50e77b8297303cea --- packaging/libmm-player.spec | 2 +- src/mm_player_priv.c | 45 ++++++++++++++++++++++++++++++++----- 2 files changed, 41 insertions(+), 6 deletions(-) diff --git a/packaging/libmm-player.spec b/packaging/libmm-player.spec index ab63c49..3c63d57 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.177 +Version: 0.6.178 Release: 0 Group: Multimedia/Libraries License: Apache-2.0 diff --git a/src/mm_player_priv.c b/src/mm_player_priv.c index 75b3e1a..de32570 100644 --- a/src/mm_player_priv.c +++ b/src/mm_player_priv.c @@ -6827,7 +6827,7 @@ __mmplayer_gst_decode_autoplug_continue(GstElement *bin, GstPad *pad, } static gboolean -__mmplayer_is_offload_supportable(mm_player_t *player) +__mmplayer_is_audio_offload_device_type(mm_player_t *player) { gboolean ret = TRUE; GDBusConnection *conn = NULL; @@ -6891,6 +6891,39 @@ DONE: return ret; } +static void __mmplayer_rebuild_audio_pipeline(mm_player_t *player) +{ + MMPlayerStateType current_state = MM_PLAYER_STATE_NONE; + gint64 position = 0; + + MMPLAYER_RETURN_IF_FAIL(player && player->attrs && + player->pipeline && player->pipeline->mainbin); + + MMPLAYER_CMD_LOCK(player); + current_state = MMPLAYER_CURRENT_STATE(player); + + if (!gst_element_query_position(player->pipeline->mainbin[MMPLAYER_M_PIPE].gst, GST_FORMAT_TIME, &position)) + LOGW("getting current position failed in paused"); + + _mmplayer_unrealize((MMHandleType)player); + _mmplayer_realize((MMHandleType)player); + + _mmplayer_set_position((MMHandleType)player, position); + + /* async not to be blocked in streaming case */ + mm_attrs_set_int_by_name(player->attrs, "profile_prepare_async", TRUE); + if (mm_attrs_commit_all(player->attrs)) + LOGE("failed to commit"); + + _mmplayer_pause((MMHandleType)player); + + if (current_state == MM_PLAYER_STATE_PLAYING) + _mmplayer_start((MMHandleType)player); + MMPLAYER_CMD_UNLOCK(player); + + LOGD("rebuilding audio pipeline is completed."); +} + void __mmplayer_audio_device_connected_cb(MMSoundDevice_t device_h, bool is_connected, void *user_data) { mm_player_t *player = (mm_player_t *)user_data; @@ -6909,14 +6942,16 @@ void __mmplayer_audio_device_connected_cb(MMSoundDevice_t device_h, bool is_conn return; } - is_supportable = __mmplayer_is_offload_supportable(player); + is_supportable = __mmplayer_is_audio_offload_device_type(player); if (player->build_audio_offload == is_supportable) { LOGD("keep current pipeline without re-building"); return; } - /* FIXME: rebuild pipeline */ - LOGD("FIXME: re-build pipeline"); + /* rebuild pipeline */ + LOGD("re-build pipeline - offload: %d", is_supportable); + player->build_audio_offload = FALSE; + __mmplayer_rebuild_audio_pipeline(player); return; } @@ -6976,7 +7011,7 @@ __mmplayer_can_build_audio_offload_path(mm_player_t *player) if (!__mmplayer_add_audio_device_connected_cb(player)) goto DONE; - if (!__mmplayer_is_offload_supportable(player)) + if (!__mmplayer_is_audio_offload_device_type(player)) goto DONE; LOGD("audio offload can be built"); -- 2.34.1