From f255180658fe252688838e47ac710367ac0c95ed Mon Sep 17 00:00:00 2001 From: Eunhae Choi Date: Tue, 26 Dec 2017 19:42:09 +0900 Subject: [PATCH] [0.6.86] customizing the bus msg polling period msg need to be handled quickly then normal state during prepare. many msg is posted during preparing kind of state change, buffering, variant, etc Change-Id: I0abeea63d44c1fcbf3e88434467e32be41ea9df7 --- packaging/libmm-player.spec | 2 +- src/include/mm_player_priv.h | 1 + src/mm_player_priv.c | 16 ++++++++++++++-- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/packaging/libmm-player.spec b/packaging/libmm-player.spec index c89b2b3..978c564 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.85 +Version: 0.6.86 Release: 0 Group: Multimedia/Libraries License: Apache-2.0 diff --git a/src/include/mm_player_priv.h b/src/include/mm_player_priv.h index 385445f..f4b6158 100644 --- a/src/include/mm_player_priv.h +++ b/src/include/mm_player_priv.h @@ -506,6 +506,7 @@ typedef struct { gboolean bus_msg_thread_exit; GCond bus_msg_thread_cond; GMutex bus_msg_thread_mutex; + gint bus_msg_timeout; /* ms */ /* fakesink handling lock */ GMutex fsink_lock; diff --git a/src/mm_player_priv.c b/src/mm_player_priv.c index 39c0887..1f51331 100644 --- a/src/mm_player_priv.c +++ b/src/mm_player_priv.c @@ -98,6 +98,9 @@ #define ADAPTIVE_VARIANT_DEFAULT_VALUE -1 /* auto */ +#define PLAYER_BUS_MSG_DEFAULT_TIMEOUT 500 /* bus msg wait timeout */ +#define PLAYER_BUS_MSG_PREPARE_TIMEOUT 100 + /*--------------------------------------------------------------------------- | LOCAL CONSTANT DEFINITIONS: | ---------------------------------------------------------------------------*/ @@ -1088,6 +1091,8 @@ void _mmplayer_bus_msg_thread_destroy(MMHandleType hplayer) MMPLAYER_FENTER(); MMPLAYER_RETURN_IF_FAIL(player); + player->bus_msg_timeout = PLAYER_BUS_MSG_DEFAULT_TIMEOUT; + /* destroy the gst bus msg thread */ if (player->bus_msg_thread) { MMPLAYER_BUS_MSG_THREAD_LOCK(player); @@ -1131,8 +1136,8 @@ static gpointer __mmplayer_gst_bus_msg_thread(gpointer data) while (!player->bus_msg_thread_exit) { msg = gst_bus_pop(bus); if (msg == NULL) { - /* set the max timeout as 500 ms */ - MMPLAYER_BUS_MSG_THREAD_WAIT_UNTIL(player, (g_get_monotonic_time() + 500 * G_TIME_SPAN_MILLISECOND)); + int timeout = (player->bus_msg_timeout > 0) ? (player->bus_msg_timeout) : (PLAYER_BUS_MSG_DEFAULT_TIMEOUT); + MMPLAYER_BUS_MSG_THREAD_WAIT_UNTIL(player, (g_get_monotonic_time() + timeout * G_TIME_SPAN_MILLISECOND)); continue; } @@ -1497,6 +1502,7 @@ __mmplayer_gst_callback(GstMessage *msg, gpointer data) case GST_STATE_PAUSED: { gboolean prepare_async = FALSE; + player->bus_msg_timeout = PLAYER_BUS_MSG_DEFAULT_TIMEOUT; if (!player->audio_cb_probe_id && player->set_mode.pcm_extraction && !player->audio_stream_render_cb_ex) __mmplayer_configure_audio_callback(player); @@ -1526,6 +1532,8 @@ __mmplayer_gst_callback(GstMessage *msg, gpointer data) case GST_STATE_PLAYING: { + player->bus_msg_timeout = PLAYER_BUS_MSG_DEFAULT_TIMEOUT; + if (MMPLAYER_IS_STREAMING(player)) { // managed prepare async case when buffering is completed // pending state should be reset otherwise, it's still playing even though it's resumed after bufferging. @@ -6787,6 +6795,7 @@ __mmplayer_gst_create_pipeline(mm_player_t* player) g_mutex_init(&player->bus_msg_thread_mutex); g_cond_init(&player->bus_msg_thread_cond); player->bus_msg_thread_exit = FALSE; + player->bus_msg_timeout = PLAYER_BUS_MSG_DEFAULT_TIMEOUT; player->bus_msg_thread = g_thread_try_new("gst_bus_msg_thread", __mmplayer_gst_bus_msg_thread, (gpointer)player, NULL); if (!player->bus_msg_thread) { @@ -8985,6 +8994,9 @@ _mmplayer_realize(MMHandleType hplayer) else ret = __mmplayer_realize_streaming_ext(player); + player->bus_msg_timeout = PLAYER_BUS_MSG_PREPARE_TIMEOUT; + MMPLAYER_BUS_MSG_THREAD_SIGNAL(player); + MMPLAYER_FLEAVE(); return ret; -- 2.7.4