Extrenal srt problem gst-1 solved.
authorchristophecvr <stefansat@telenet.be>
Sat, 25 Jul 2015 11:31:42 +0000 (13:31 +0200)
committerchristophecvr <stefansat@telenet.be>
Sat, 25 Jul 2015 11:31:42 +0000 (13:31 +0200)
To have all the media always in sync.
Subtitles must run in sync by gst-1.
Since by base enigma2.bb file for gst-1.
The patch disable sub is not there anymore.
For gst-1 the subtitle sync is enabled by default.
The extren subtitles can have from time to time a warning.
That's now solved and all subtitles internal/extrenal,
Are starting well and synced.

modified:   lib/service/servicemp3.cpp
modified:   lib/service/servicemp3.h

lib/service/servicemp3.cpp
lib/service/servicemp3.h

index 2d7c4bd..d140f99 100644 (file)
@@ -67,7 +67,11 @@ typedef enum
  * see: https://bugzilla.gnome.org/show_bug.cgi?id=619434
  * As a workaround, we run the subsink in sync=false mode
  */
+#if GST_VERSION_MAJOR < 1 
 #define GSTREAMER_SUBTITLE_SYNC_MODE_BUG
+#else
+#undef GSTREAMER_SUBTITLE_SYNC_MODE_BUG
+#endif
 /**/
 
 eServiceFactoryMP3::eServiceFactoryMP3()
@@ -414,6 +418,7 @@ eServiceMP3::eServiceMP3(eServiceReference ref):
 #if GST_VERSION_MAJOR >= 1
        m_use_chapter_entries = false; /* TOC chapter support CVR */
        m_user_paused = false; /* CVR */
+       m_last_seek_pos = 0; /* CVR last seek position */
 #endif
        m_extra_headers = "";
        m_download_buffer_path = "";
@@ -850,10 +855,17 @@ RESULT eServiceMP3::getLength(pts_t &pts)
 RESULT eServiceMP3::seekToImpl(pts_t to)
 {
                /* convert pts to nanoseconds */
+#if GST_VERSION_MAJOR < 1
        gint64 time_nanoseconds = to * 11111LL;
        if (!gst_element_seek (m_gst_playbin, m_currentTrickRatio, GST_FORMAT_TIME, (GstSeekFlags)(GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_KEY_UNIT),
                GST_SEEK_TYPE_SET, time_nanoseconds,
                GST_SEEK_TYPE_NONE, GST_CLOCK_TIME_NONE))
+#else
+       m_last_seek_pos = to * 11111LL;
+       if (!gst_element_seek (m_gst_playbin, m_currentTrickRatio, GST_FORMAT_TIME, (GstSeekFlags)(GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_KEY_UNIT),
+               GST_SEEK_TYPE_SET, m_last_seek_pos,
+               GST_SEEK_TYPE_NONE, GST_CLOCK_TIME_NONE))
+#endif
        {
                eDebug("[eServiceMP3] seekTo failed");
                return -1;
@@ -1542,6 +1554,7 @@ void eServiceMP3::gstBusCall(GstMessage *msg)
                return;
        gchar *sourceName;
        GstObject *source;
+       GstElement *subsink;
        source = GST_MESSAGE_SRC(msg);
        if (!GST_IS_OBJECT(source))
                return;
@@ -1594,7 +1607,7 @@ void eServiceMP3::gstBusCall(GstMessage *msg)
                                        GValue result = { 0, };
 #endif
                                        GstIterator *children;
-                                       GstElement *subsink = gst_bin_get_by_name(GST_BIN(m_gst_playbin), "subtitle_sink");
+                                       subsink = gst_bin_get_by_name(GST_BIN(m_gst_playbin), "subtitle_sink");
                                        if (subsink)
                                        {
 #ifdef GSTREAMER_SUBTITLE_SYNC_MODE_BUG
@@ -1723,6 +1736,35 @@ void eServiceMP3::gstBusCall(GstMessage *msg)
                        g_error_free(err);
                        break;
                }
+#if GST_VERSION_MAJOR >= 1
+               case GST_MESSAGE_WARNING:
+               {
+                       gchar *debug_warn = NULL;
+                       GError *warn = NULL;
+                       gst_message_parse_warning (msg, &warn, &debug_warn);
+                       /* CVR this Warning occurs from time to time with external srt files
+                       When a new seek is done the problem off to long wait times before subtitles appears,
+                       after movie was restarted with a resume position is solved. */
+                       if(!strncmp(warn->message , "Internal data flow problem", 26) && !strncmp(sourceName, "subtitle_sink", 13))
+                       {
+                               eWarning("[eServiceMP3] Gstreamer warning : %s (%i) from %s" , warn->message, warn->code, sourceName);
+                               subsink = gst_bin_get_by_name(GST_BIN(m_gst_playbin), "subtitle_sink");
+                               if(subsink)
+                               {
+                                       if (!gst_element_seek (subsink, m_currentTrickRatio, GST_FORMAT_TIME, (GstSeekFlags)(GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_KEY_UNIT),
+                                               GST_SEEK_TYPE_SET, m_last_seek_pos,
+                                               GST_SEEK_TYPE_NONE, GST_CLOCK_TIME_NONE))
+                                       {
+                                               eDebug("[eServiceMP3] seekToImpl subsink failed");
+                                       }
+                                       gst_object_unref(subsink);
+                               }
+                       }
+                       g_free(debug_warn);
+                       g_error_free(warn);
+                       break;
+               }
+#endif
                case GST_MESSAGE_INFO:
                {
                        gchar *debug;
index 038a8a5..c8a9fe7 100644 (file)
@@ -308,6 +308,8 @@ private:
        bool m_use_chapter_entries;
        /* CVR needed for user requested media pause */
        bool m_user_paused;
+       /* last used seek position gst-1 only */
+       gint64 m_last_seek_pos;
 #endif
        bufferInfo m_bufferInfo;
        errorInfo m_errorInfo;