[MPlayer-cvslog] r37969 - in trunk/gui: interface.c ui/actions.c ui/actions.h

ib subversion at mplayerhq.hu
Thu Oct 5 13:16:42 EEST 2017


Author: ib
Date: Thu Oct  5 13:16:41 2017
New Revision: 37969

Log:
Optimize playback of cue sheet playlists.

Make it smoother.

Don't stop after playback of a track and seek to (the same position for)
the next track, because that may cause a small but noticeable playback
glitch - especially if the track transitions to the next one.

Instead, just update track information and continue playing.

Modified:
   trunk/gui/interface.c
   trunk/gui/ui/actions.c
   trunk/gui/ui/actions.h

Modified: trunk/gui/interface.c
==============================================================================
--- trunk/gui/interface.c	Thu Oct  5 13:00:49 2017	(r37968)
+++ trunk/gui/interface.c	Thu Oct  5 13:16:41 2017	(r37969)
@@ -406,6 +406,7 @@ void guiDone(void)
 int gui(int what, void *data)
 {
     static float last_balance = -1.0f;
+    static int last_playlistnext = True;
 #ifdef CONFIG_DVDREAD
     dvd_priv_t *dvd;
 #endif
@@ -447,8 +448,7 @@ int gui(int what, void *data)
         wsMouseAutohide();
         gtkEvents();
 
-        if (guiInfo.Stop && (guiInfo.ElapsedTime >= guiInfo.Stop))
-            guiInfo.MediumChanged = GUI_MEDIUM_NEW;
+        uiCueCheckNext(&last_playlistnext);
 
         break;
 
@@ -1007,6 +1007,8 @@ int gui(int what, void *data)
         uiEvent(ivRedraw, True);
 
         if (guiInfo.Playing) {
+            last_playlistnext = guiInfo.PlaylistNext;
+
             if (!guiInfo.PlaylistNext) {
                 guiInfo.PlaylistNext = True;
                 break;

Modified: trunk/gui/ui/actions.c
==============================================================================
--- trunk/gui/ui/actions.c	Thu Oct  5 13:00:49 2017	(r37968)
+++ trunk/gui/ui/actions.c	Thu Oct  5 13:16:41 2017	(r37969)
@@ -981,3 +981,47 @@ void uiNext(void)
     else if (!stop && !next && unset)
         uiUnsetMedia(True);
 }
+
+/**
+ * @brief Check whether the end of a cue sheet playlist track has been
+ *        reached and set #guiInfo information for the next track.
+ *
+ * @param set whether to set next track's information or skip setting
+ *            information once
+ *
+ * @note Parameter @a set will be set for next call of the function.
+ *
+ * @return #True (information for next track has been set),
+ *         #False (end not yet reached) or -1 (@a set was #False)
+ */
+int uiCueCheckNext(int *set)
+{
+    plItem *next;
+
+    if (guiInfo.Stop && (guiInfo.ElapsedTime >= guiInfo.Stop)) {
+        if (!*set) {
+            *set = True;
+            return -1;
+        }
+
+        next = listMgr(PLAYLIST_ITEM_GET_NEXT, 0);
+
+        if (next) {
+            free(guiInfo.Title);
+            guiInfo.Title = gstrdup(next->title);
+            guiInfo.Track = (uintptr_t)listMgr(PLAYLIST_ITEM_GET_POS, next);
+            guiInfo.Start = next->start;
+            guiInfo.Stop  = next->stop;
+
+            if (guiInfo.ElapsedTime != guiInfo.Start) {
+                guiInfo.PlaylistNext  = False;
+                guiInfo.MediumChanged = GUI_MEDIUM_NEW;
+            }
+
+            *set = False;
+        }
+
+        return True;
+    } else
+        return False;
+}

Modified: trunk/gui/ui/actions.h
==============================================================================
--- trunk/gui/ui/actions.h	Thu Oct  5 13:00:49 2017	(r37968)
+++ trunk/gui/ui/actions.h	Thu Oct  5 13:16:41 2017	(r37969)
@@ -25,6 +25,7 @@ extern int uiLoadPlay;
 
 void uiAbsSeek(float sec);
 void uiChangeSkin(char *name);
+int uiCueCheckNext(int *);
 void uiCurr(void);
 void uiEvent(int ev, float param);
 void uiFullScreen(void);


More information about the MPlayer-cvslog mailing list