[MPlayer-dev-eng] [PATCH] Extra messages in slave mode

Andras Mohari mayday at mailpont.hu
Mon Dec 5 13:05:46 CET 2005


Hi,

I've seen a message on mplayer-users ("how to get the OEF with using
mplayer slave ?" by Alexandre CONRAD <aconrad.tlv at magic.fr>) about the
hardships of detecting when MPlayer stops playing in idle mode.
I think that all frontends could benefit from MPlayer printing some
useful, easy to parse and unambiguous messages when something
interesting happens, not just when you use a get_* slave command or
something.

So this patch makes 'mplayer -slave' print some lines starting with
SLAVE_ to indicate what it is doing. These are:

* SLAVE_FILE <filename>
  Printed when MPlayer is about to play a file.

* SLAVE_PLAYING
  Printed when MPlayer actually starts playing.

* SLAVE_PAUSED and SLAVE_UNPAUSED
  Printed _every time_ MPlayer is paused/unpaused. (Not just in
  response to the 'pause' command.) So, for example, you'll get this when
  sending the 'frame_step' command while paused:

        SLAVE_UNPAUSED
        SLAVE_PAUSED

* SLAVE_STOPPED
  Printed when MPlayer finished playing the current file. (But not when
  you quit or kill the player.)


I wonder what you think about these. And please note that I had a hard
time finding my way in mplayer.c, so I'm not at all sure if I 
managed to get things right. In other words: I've probably got it all
wrong, though it seems to work for me. (I've tried it with some files
and a DVD, nothing else.)

-- 
Andras Mohari
-------------- next part --------------
Index: mplayer.c
===================================================================
RCS file: /cvsroot/mplayer/main/mplayer.c,v
retrieving revision 1.891
diff -u -r1.891 mplayer.c
--- mplayer.c	5 Dec 2005 01:18:10 -0000	1.891
+++ mplayer.c	5 Dec 2005 11:16:27 -0000
@@ -1826,7 +1826,10 @@
 }
 //---------------------------------------------------------------------------
 
-    if(filename) mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_Playing, filename);
+    if(filename) {
+      mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_Playing, filename);
+      if(slave_mode) mp_msg(MSGT_GLOBAL,MSGL_INFO, "SLAVE_FILE %s\n", filename);
+    }
 
 //==================== Open VOB-Sub ============================
 
@@ -2553,7 +2556,9 @@
 if(loop_times>1) loop_times--; else
 if(loop_times==1) loop_times = -1;
 
-mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_StartPlaying);fflush(stdout);
+mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_StartPlaying);
+if(slave_mode) mp_msg(MSGT_GLOBAL,MSGL_INFO,"SLAVE_PLAYING\n");
+fflush(stdout);
 
 #ifdef USE_DVDNAV
 if (stream->type==STREAMTYPE_DVDNAV) {
@@ -3012,6 +3017,10 @@
           mp_msg(MSGT_GLOBAL, MSGL_INFO, "ID_PAUSED\n");
 	fflush(stdout);
       }
+      if(slave_mode) {
+        mp_msg(MSGT_GLOBAL,MSGL_INFO, "SLAVE_PAUSED\n");
+        fflush(stdout);
+      }
 #ifdef HAVE_NEW_GUI
       if(use_gui) guiGetEvent( guiCEvent,(char *)guiSetPause );
 #endif
@@ -3053,6 +3062,10 @@
         guiGetEvent( guiCEvent,(char *)guiSetPlay );
        }
 #endif
+      if(slave_mode) {
+        mp_msg(MSGT_GLOBAL,MSGL_INFO, "SLAVE_UNPAUSED\n");
+        fflush(stdout);
+      }
   }
 
 // handle -sstep
@@ -4522,6 +4535,11 @@
   }	
 #endif
 
+if(slave_mode) {
+  mp_msg(MSGT_GLOBAL,MSGL_INFO, "SLAVE_STOPPED\n");
+  fflush(stdout);
+}
+
 if(use_gui || playtree_iter != NULL || player_idle_mode){
   if (!playtree_iter) filename = NULL;
   eof = 0;


More information about the MPlayer-dev-eng mailing list