[MPlayer-cvslog] r35604 - in trunk: gui/interface.c gui/interface.h gui/win32/interface.c mplayer.c

ib subversion at mplayerhq.hu
Wed Dec 5 12:51:08 CET 2012


Author: ib
Date: Wed Dec  5 12:51:08 2012
New Revision: 35604

Log:
Combine guiPlaylistInitialize() and guiPlaylistAdd().

New guiPlaylist() handles both now according to the instruction
passed to it.

Modified:
   trunk/gui/interface.c
   trunk/gui/interface.h
   trunk/gui/win32/interface.c
   trunk/mplayer.c

Modified: trunk/gui/interface.c
==============================================================================
--- trunk/gui/interface.c	Wed Dec  5 09:35:23 2012	(r35603)
+++ trunk/gui/interface.c	Wed Dec  5 12:51:08 2012	(r35604)
@@ -853,14 +853,18 @@ int gui(int what, void *data)
     return True;
 }
 
+int guiPlaylist(int what, play_tree_t *my_playtree, m_config_t *config, int enqueue)
+{
+    play_tree_iter_t *my_pt_iter = NULL;
+    int added = False;
+    plItem *save;
+
+    switch (what) {
 // This function imports the initial playtree (based on cmd-line files)
 // into the gui playlist by either:
 // - overwriting gui pl (enqueue=0)
 // - appending it to gui pl (enqueue=1)
-int guiPlaylistInitialize(play_tree_t *my_playtree, m_config_t *config, int enqueue)
-{
-    play_tree_iter_t *my_pt_iter = NULL;
-    int added = False;
+    case GUI_PLAYLIST_INIT:
 
     if (!enqueue)
         listMgr(PLAYLIST_DELETE, 0);             // delete playlist before "appending"
@@ -881,19 +885,14 @@ int guiPlaylistInitialize(play_tree_t *m
     if (added)
         guiInfo.Track = 1;
 
-    return added;
-}
+        break;
 
 // This function imports and inserts an playtree, that is created "on the fly",
 // for example by parsing some MOV-Reference-File; or by loading an playlist
 // with "File Open". (The latter, actually, isn't allowed in MPlayer and thus
 // not working which is why this function won't get called for that reason.)
 // The file which contained the playlist is thereby replaced with it's contents.
-int guiPlaylistAdd(play_tree_t *my_playtree, m_config_t *config)
-{
-    play_tree_iter_t *my_pt_iter = NULL;
-    int added = False;
-    plItem *save;
+    case GUI_PLAYLIST_ADD:
 
     save = (plItem *)listMgr(PLAYLIST_ITEM_GET_CURR, 0);    // save current item
 
@@ -916,6 +915,9 @@ int guiPlaylistAdd(play_tree_t *my_playt
 
     uiCurr();   // update filename
 
+        break;
+    }
+
     return added;
 }
 

Modified: trunk/gui/interface.h
==============================================================================
--- trunk/gui/interface.h	Wed Dec  5 09:35:23 2012	(r35603)
+++ trunk/gui/interface.h	Wed Dec  5 12:51:08 2012	(r35604)
@@ -55,6 +55,12 @@ enum {
     GUI_SET_VIDEO
 };
 
+/// guiPlaylist() instructions
+enum {
+    GUI_PLAYLIST_INIT,
+    GUI_PLAYLIST_ADD
+};
+
 //@{
 /// Playing state
 #define GUI_STOP  0
@@ -140,8 +146,7 @@ extern guiInterface_t guiInfo;
 int gui(int what, void *data);
 void guiDone(void);
 void guiInit(void);
-int guiPlaylistAdd(play_tree_t *my_playtree, m_config_t *config);
-int guiPlaylistInitialize(play_tree_t *my_playtree, m_config_t *config, int enqueue);
+int guiPlaylist(int what, play_tree_t *my_playtree, m_config_t *config, int enqueue);
 //@}
 
 /// @name GUI -> MPlayer

Modified: trunk/gui/win32/interface.c
==============================================================================
--- trunk/gui/win32/interface.c	Wed Dec  5 09:35:23 2012	(r35603)
+++ trunk/gui/win32/interface.c	Wed Dec  5 12:51:08 2012	(r35604)
@@ -182,7 +182,7 @@ int parse_filename(char *file, play_tree
     if(strstr(file, ".m3u") || strstr(file, ".pls"))
     {
         playtree = parse_playlist_file(file);
-        guiPlaylistAdd(playtree, mconfig);
+        guiPlaylist(GUI_PLAYLIST_ADD, playtree, mconfig, 0);
         return 1;
     }
     return 0;
@@ -457,8 +457,8 @@ void uiSetFile(char *dir, char *name, in
 
     filename = guiInfo.Filename;
 #ifdef __WINE__
-    // When the GUI receives the files to be played in guiPlaylistInitialize()
-    // and guiPlaylistAdd(), it calls import_file_into_gui() where the call of
+    // When the GUI receives the files to be played in guiPlaylist(),
+    // it calls import_file_into_gui() where the call of
     // Wine's GetFullPathName() converts each file name into the Windows style
     // (C:\path\to\file), which needs to be reconverted for MPlayer, so that
     // it will find the filename in the Linux filesystem.
@@ -842,15 +842,18 @@ static int import_file_into_gui(char *pa
     return 0;
 }
 
-/*  This function imports the initial playtree (based on cmd-line files) into the gui playlist
-    by either:
-    - overwriting gui pl (enqueue=0) */
-
-int guiPlaylistInitialize(play_tree_t *my_playtree, m_config_t *config, int enqueue)
+int guiPlaylist (int what, play_tree_t *my_playtree, m_config_t *config, int enqueue)
 {
     play_tree_iter_t *my_pt_iter = NULL;
     int added = FALSE;
 
+    switch (what)
+    {
+/*  This function imports the initial playtree (based on cmd-line files) into the gui playlist
+    by either:
+    - overwriting gui pl (enqueue=0) */
+      case GUI_PLAYLIST_INIT:
+
     if(!mygui) guiInit();
 
     if((my_pt_iter = pt_iter_create(&my_playtree, config)))
@@ -873,17 +876,12 @@ int guiPlaylistInitialize(play_tree_t *m
 
     if (enqueue) filename = NULL;
 
-    return added;
-}
+          break;
 
 /* This function imports and inserts an playtree, that is created "on the fly", for example by
    parsing some MOV-Reference-File; or by loading an playlist with "File Open"
    The file which contained the playlist is thereby replaced with it's contents. */
-
-int guiPlaylistAdd(play_tree_t *my_playtree, m_config_t *config)
-{
-    play_tree_iter_t *my_pt_iter = NULL;
-    int added = FALSE;
+        case GUI_PLAYLIST_ADD:
 
     if((my_pt_iter = pt_iter_create(&my_playtree, config)))
     {
@@ -892,6 +890,10 @@ int guiPlaylistAdd(play_tree_t *my_playt
                 added = TRUE;
         pt_iter_destroy(&my_pt_iter);
     }
+
+          break;
+    }
+
     return added;
 }
 

Modified: trunk/mplayer.c
==============================================================================
--- trunk/mplayer.c	Wed Dec  5 09:35:23 2012	(r35603)
+++ trunk/mplayer.c	Wed Dec  5 12:51:08 2012	(r35604)
@@ -1033,7 +1033,7 @@ static int playtree_add_playlist(play_tr
 #ifdef CONFIG_GUI
     if (use_gui) {
         if (entry) {
-            guiPlaylistAdd(entry, mconfig);
+            guiPlaylist(GUI_PLAYLIST_ADD, entry, mconfig, 0);
             play_tree_free_list(entry, 1);
         }
     } else
@@ -2859,7 +2859,7 @@ int main(int argc, char *argv[])
             play_tree_add_bpf(mpctx->playtree, cwd);
         }
         // Import initital playtree into GUI.
-        guiPlaylistInitialize(mpctx->playtree, mconfig, enqueue);
+        guiPlaylist(GUI_PLAYLIST_INIT, mpctx->playtree, mconfig, enqueue);
     }
 #endif /* CONFIG_GUI */
 


More information about the MPlayer-cvslog mailing list