[MPlayer-users] My question of the hour, does anyone know source inside out?

Sara Glade saraglade at yahoo.com
Sat Dec 22 04:48:44 CET 2007



>> In answer to your question: if you want MPlayer's playback window
>> to remain open after playback finishes (e.g. so that you can send
>> it commands via slave mode), you need the '-idle' option.

> It appears, please correct me if I am mistaken, but I need a
> so-called 'slave-idle.patch' to enable this functionality? :-)

>> I've never heard of this, as far as I remember. Certainly I have a hard
>> time thinking of a use for '-idle' which would not involve opening a
>> file after the program goes into idle, which AFAIR can only be done via
>>
 slave mode (and perhaps via the OSD menu, but I've never had occasion
 to
>> even find out how to bring that up); if '-idle' would not work with
>> slave mode, there seems little point to having it at all.
>> 
>> I would recommend that you try it without the patch first, and if it
>> fails to work at all, then perhaps consider attempting to apply the
>> patch (and/or, as is more likely, adapt the patch to be able to be
>> applied to the most recent version of the source code).

Very good and informative.  I actually surmised the slave-idle.patch was
probably prior to RC2 and therefore not going to fit perfect, however,
even with my limited skill in building these, I managed to understand the
diagram in the patch text.  I've cut-and-pasted the slave-idle.patch
below.  Maybe you can help me understand how to merge where I am
failing.

So, I am indeed working with the latest RC2 build, and presume by
looking at this
 patch there are going to be two files to be 'patched'

cfg-mplayer.h
mplayer.c

It is my understanding the + and - in this patch text signify the addition
or removal of certain lines, ... and the bits demarcated between @@ @@
are like reference pointers to which lines where they need to go.

Maybe this is well beyond comprehension to install into RC2, and maybe
even I am using the wrong way to use IDLE.

I am 

> mplayer videofile.avi -idle

(result I am expecting is for the video file to play to the very end,
and the window in which the video was rendered will just stay put
and not close :-)


So, therefore, below this patch, I have demonstrated how I 'patched up'
cfg-mplayer.h (before and after).  The mplayer.c is a little convoluted,
but maybe you can see clearer than I can, and hopefully can show me
the way.  

This was my attempt to apply this patch, before and after:

http://www.myfilestash.com/userfiles/sara22glade/CFG-MPLAYER.H_modified.txt

http://www.myfilestash.com/userfiles/sara22glade/CFG-MPLAYER.H_unmodified.txt



http://www.myfilestash.com/userfiles/sara22glade/MPLAYER.C_checkit.txt


Anything to achieve the effect I am looking for would be graciously accepted. :-) Be well, Sara.


0000000000000000000000000000000000000000000000000000
-IDLE SWITCH PATCH
0000000000000000000000000000000000000000000000000000

Index: cfg-mplayer.h
===================================================================
RCS file: /cvsroot/mplayer/main/cfg-mplayer.h,v
retrieving revision 1.242
diff -u -r1.242 cfg-mplayer.h
--- cfg-mplayer.h    23 Feb 2005 01:43:15 -0000    1.242
+++ cfg-mplayer.h    27 Feb 2005 10:37:18 -0000
@@ -397,6 +397,8 @@
 #endif
 
     {"slave", &slave_mode, CONF_TYPE_FLAG,CONF_GLOBAL , 0, 1, NULL},
+    {"idle", &player_idle_mode, CONF_TYPE_FLAG,CONF_GLOBAL , 0, 1, NULL},
+    {"noidle", &player_idle_mode, CONF_TYPE_FLAG,CONF_GLOBAL , 0, 0, NULL}, 
     {"use-stdin", "-use-stdin has been renamed to
 -noconsolecontrols, use that instead.", CONF_TYPE_PRINT, 0, 0, 0, NULL},
     {"key-fifo-size", &key_fifo_size, CONF_TYPE_INT, CONF_RANGE, 2, 65000, NULL},
     {"noconsolecontrols", &noconsolecontrols, CONF_TYPE_FLAG, CONF_GLOBAL, 0, 1, NULL},
Index: mplayer.c
===================================================================
RCS file: /cvsroot/mplayer/main/mplayer.c,v
retrieving revision 1.835
diff -u -r1.835 mplayer.c
--- mplayer.c    25 Feb 2005 11:11:07 -0000    1.835
+++ mplayer.c    27 Feb 2005 10:37:23 -0000
@@ -84,6 +84,7 @@
 #include "input/input.h"
 
 int slave_mode=0;
+int player_idle_mode=0;
 int verbose=0;
 int identify=0;
 int quiet=0;
@@ -1259,7 +1260,12 @@
 }
 #endif
 
-    if(!filename){
+    if
 (player_idle_mode && use_gui) {
+        mp_msg(MSGT_CPLAYER, MSGL_FATAL, MSGTR_NoIdleAndGui);
+        exit_player_with_rc(NULL, 1);
+    }
+
+    if(!filename && !player_idle_mode){
       if(!use_gui){
     // no file/vcd/dvd -> show HELP:
     mp_msg(MSGT_CPLAYER, MSGL_INFO, help_text);
@@ -1486,6 +1492,48 @@
        } 
     }
 #endif
+
+while (player_idle_mode && !filename) {
+    play_tree_t * entry = NULL;
+    mp_cmd_t * cmd;
+    while (!(cmd = mp_input_get_cmd(0,1,0))) usec_sleep(30000); // wait for command
+    switch (cmd->id) {
+       
 case MP_CMD_LOADFILE:
+            // prepare a tree entry with the new filename
+            entry = play_tree_new();
+            play_tree_add_file(entry, cmd->args[0].v.s);
+            // actual entering the entry into the main playtree done after switch()
+            break;
+        case MP_CMD_LOADLIST:
+            entry = parse_playlist_file(cmd->args[0].v.s);
+            break;
+        case MP_CMD_QUIT:   
 
+            exit_player_with_rc(MSGTR_Exit_quit, (cmd->nargs > 0)? cmd->args[0].v.i : 0);
+            break;                
+    }
+        
+    if (entry) { // user entered a command that gave a valid entry
+        if (playtree) // the playtree is always a node with one child. let's clear it
+            play_tree_free_list(playtree->child, 1);
+        else playtree=play_tree_new(); // .. or make a brand new playtree
+        
+        if (!playtree) continue; //
 couldn't make playtree! wait for next command
+            
+        play_tree_set_child(playtree, entry);
+        
+        playtree_iter = play_tree_iter_new(playtree, mconfig); // make iterator starting at top of tree
+        if (!playtree_iter) continue;
+        
+        // find the first real item in the tree
+        if (play_tree_iter_step(playtree_iter,0,0) != PLAY_TREE_ITER_ENTRY) {
+            // no items!
+           
 play_tree_iter_free(playtree_iter);
+            playtree_iter = NULL;
+            continue; // wait for next command
+        }
+        filename = play_tree_iter_get_file(playtree_iter, 1);
+    }
+}
 //---------------------------------------------------------------------------
 
     if(filename) mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_Playing, filename);
@@ -4174,8 +4222,8 @@
   }    
 #endif
 
-if(use_gui || playtree_iter != NULL){
-
+if(use_gui || playtree_iter != NULL || player_idle_mode){
+  if (!playtree_iter) filename = NULL;
   eof = 0;
   goto play_next_file;
 }
Index:
 help/help_mp-en.h
===================================================================
RCS file: /cvsroot/mplayer/main/help/help_mp-en.h,v
retrieving revision 1.162
diff -u -r1.162 help_mp-en.h
--- help/help_mp-en.h    26 Feb 2005 23:03:53 -0000    1.162
+++ help/help_mp-en.h    27 Feb 2005 10:37:32 -0000
@@ -159,6 +159,7 @@
 #define MSGTR_IncreaseRTCMaxUserFreq "Try adding \"echo %lu > /proc/sys/dev/rtc/max-user-freq\" to your system startup scripts.\n"
 #define MSGTR_LinuxRTCInitErrorPieOn "Linux RTC init error in ioctl (rtc_pie_on): %s\n"
 #define MSGTR_UsingTimingType "Using %s timing.\n"
+#define MSGTR_NoIdleAndGui "The -idle option cannot be used with GUI MPlayer.\n"
 #define MSGTR_MenuInitialized "Menu inited: %s\n"
 #define MSGTR_MenuInitFailed "Menu init failed.\n"
 #define MSGTR_Getch2InitializedTwice "WARNING: getch2_init
 called twice!\n"


0000000000000000000000000000000000000000000000000000
END OF IDLE PATCH

0000000000000000000000000000000000000000000000000000












      ____________________________________________________________________________________
Be a better friend, newshound, and 
know-it-all with Yahoo! Mobile.  Try it now.  http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ 



More information about the MPlayer-users mailing list