[0.6.86] customizing the bus msg polling period 32/165132/2 accepted/tizen/4.0/unified/20180102.065537 submit/tizen_4.0/20171227.040847
authorEunhae Choi <eunhae1.choi@samsung.com>
Tue, 26 Dec 2017 10:42:09 +0000 (19:42 +0900)
committerEunhae Choi <eunhae1.choi@samsung.com>
Tue, 26 Dec 2017 10:45:47 +0000 (19:45 +0900)
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
src/include/mm_player_priv.h
src/mm_player_priv.c

index c89b2b3..978c564 100644 (file)
@@ -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
index 385445f..f4b6158 100644 (file)
@@ -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;
index 39c0887..1f51331 100644 (file)
@@ -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;