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

ib subversion at mplayerhq.hu
Sun Dec 2 01:36:56 CET 2012


Author: ib
Date: Sun Dec  2 01:36:56 2012
New Revision: 35552

Log:
Add listMgr command PLAYLIST_ITEM_GET_CURR_POS.

Use this command to retrieve the "track number" of a playlist playback
instead of simply incrementing or decrementing it.

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

Modified: trunk/gui/interface.c
==============================================================================
--- trunk/gui/interface.c	Sun Dec  2 00:45:59 2012	(r35551)
+++ trunk/gui/interface.c	Sun Dec  2 01:36:56 2012	(r35552)
@@ -787,7 +787,7 @@ int gui(int what, void *data)
         if (guiInfo.Playing && next) {
             uiSetFile(next->path, next->name, STREAMTYPE_FILE);
             guiInfo.NewPlay = GUI_FILE_NEW;
-            guiInfo.Track++;
+            guiInfo.Track   = (int)listMgr(PLAYLIST_ITEM_GET_POS, next);
         } else {
             if (guiInfo.NewPlay == GUI_FILE_NEW)
                 break;

Modified: trunk/gui/ui/actions.c
==============================================================================
--- trunk/gui/ui/actions.c	Sun Dec  2 00:45:59 2012	(r35551)
+++ trunk/gui/ui/actions.c	Sun Dec  2 01:36:56 2012	(r35552)
@@ -384,7 +384,7 @@ void uiPrev(void)
         if (prev) {
             uiSetFile(prev->path, prev->name, STREAMTYPE_FILE);
             guiInfo.PlaylistNext = (guiInfo.Playing ? 0 : 1);
-            guiInfo.Track--;
+            guiInfo.Track = (int)listMgr(PLAYLIST_ITEM_GET_POS, prev);
             break;
         }
 
@@ -440,7 +440,7 @@ void uiNext(void)
         if (next) {
             uiSetFile(next->path, next->name, STREAMTYPE_FILE);
             guiInfo.PlaylistNext = (guiInfo.Playing ? 0 : 1);
-            guiInfo.Track++;
+            guiInfo.Track = (int)listMgr(PLAYLIST_ITEM_GET_POS, next);
             break;
         }
 

Modified: trunk/gui/util/list.c
==============================================================================
--- trunk/gui/util/list.c	Sun Dec  2 00:45:59 2012	(r35551)
+++ trunk/gui/util/list.c	Sun Dec  2 01:36:56 2012	(r35552)
@@ -45,9 +45,12 @@ static urlItem *urlList;
  *         pointer to current list item (ITEM command) or
  *         NULL (DELETE or unknown command)
  *
+ * @note PLAYLIST_ITEM_GET_POS returns the position number as pointer,
+ *       and position 0 means "not found"
  */
 void *listMgr(int cmd, void *data)
 {
+    unsigned int pos;
     plItem *pdat  = (plItem *)data;
     urlItem *udat = (urlItem *)data;
 
@@ -102,6 +105,28 @@ void *listMgr(int cmd, void *data)
 
         return plCurrent;
 
+    case PLAYLIST_ITEM_GET_POS:
+
+        pos = 0;
+
+        if (plList) {
+            unsigned int i = 0;
+            plItem *item   = plList;
+
+            do {
+                i++;
+
+                if (item == pdat) {
+                    pos = i;
+                    break;
+                }
+
+                item = item->next;
+            } while (item);
+        }
+
+        return (void *)pos;
+
     case PLAYLIST_ITEM_GET_PREV:
 
         if (plCurrent && plCurrent->prev) {

Modified: trunk/gui/util/list.h
==============================================================================
--- trunk/gui/util/list.h	Sun Dec  2 00:45:59 2012	(r35551)
+++ trunk/gui/util/list.h	Sun Dec  2 01:36:56 2012	(r35552)
@@ -26,6 +26,7 @@ enum {
     PLAYLIST_ITEM_INSERT,
     PLAYLIST_ITEM_SET_CURR,
     PLAYLIST_ITEM_GET_CURR,
+    PLAYLIST_ITEM_GET_POS,
     PLAYLIST_ITEM_GET_PREV,
     PLAYLIST_ITEM_GET_NEXT,
     PLAYLIST_ITEM_DEL_CURR,


More information about the MPlayer-cvslog mailing list