[0.6.262] resolve block issue during switching stream 34/265034/3
authorEunhye Choi <eunhae1.choi@samsung.com>
Thu, 7 Oct 2021 09:37:38 +0000 (18:37 +0900)
committerEunhye Choi <eunhae1.choi@samsung.com>
Fri, 8 Oct 2021 03:20:25 +0000 (12:20 +0900)
- resolve block issue by sending seek event
  when stream is switched (as audio only scenarios)
  during paused state.
- demux task could not push data for newly added track
  because it is waiting to push the previous track data but
  the buffer could be full in paused state.

Change-Id: I415c7435654a0977e0f61453a76f608d16e25698

packaging/libmm-player.spec
src/include/mm_player_utils.h
src/mm_player_priv.c

index 46af763..e9cee51 100644 (file)
@@ -1,6 +1,6 @@
 Name:       libmm-player
 Summary:    Multimedia Framework Player Library
-Version:    0.6.261
+Version:    0.6.262
 Release:    0
 Group:      Multimedia/Libraries
 License:    Apache-2.0
index 543c5b0..b85e693 100644 (file)
 #define MMPLAYER_GENERATE_DOT_IF_ENABLED(x_player, x_name) \
        do { \
                if (x_player->ini.generate_dot) { \
-                       GST_DEBUG_BIN_TO_DOT_FILE(GST_BIN(player->pipeline->mainbin[MMPLAYER_M_PIPE].gst), \
+                       GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS(GST_BIN(player->pipeline->mainbin[MMPLAYER_M_PIPE].gst), \
                        GST_DEBUG_GRAPH_SHOW_ALL, x_name); \
                } \
        } while (0)
index 3c10d20..b4114f0 100644 (file)
@@ -1449,6 +1449,7 @@ ERROR:
                sinkpad = NULL;
        }
 
+       MMPLAYER_GENERATE_DOT_IF_ENABLED(player, "pipeline-pad-added");
        return;
 }
 
@@ -8524,6 +8525,24 @@ __mmplayer_switch_stream(mmplayer_t *player, mmplayer_track_type_e type, int ind
                g_list_free(streams);
        }
 
+       /* in paused state, seek to current pos to flush mq buffer and release waiting task */
+       if (MMPLAYER_CURRENT_STATE(player) == MM_PLAYER_STATE_PAUSED) {
+               gint64 pos_nsec = GST_CLOCK_TIME_NONE;
+
+               if (!gst_element_query_position(player->pipeline->mainbin[MMPLAYER_M_PIPE].gst, GST_FORMAT_TIME, &pos_nsec))
+                       pos_nsec = player->last_position;
+
+               LOGD("current pos %" GST_TIME_FORMAT ", rate = %f", GST_TIME_ARGS(pos_nsec), player->playback_rate);
+
+               if (!_mmplayer_gst_seek(player, player->pipeline->mainbin[MMPLAYER_M_PIPE].gst,
+                                       player->playback_rate, GST_FORMAT_TIME,
+                                       (GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_ACCURATE),
+                                       GST_SEEK_TYPE_SET, pos_nsec, GST_SEEK_TYPE_SET, GST_CLOCK_TIME_NONE)) {
+                       LOGW("failed to seek");
+                       return MM_ERROR_PLAYER_INTERNAL;
+               }
+       }
+
        MMPLAYER_FLEAVE();
        return MM_ERROR_NONE;
 }