[MPlayer-users] [PATCH] Add option to read -slave commands from fifo

Bernhard Rosenkraenzer bero at arklinux.org
Tue Apr 8 14:10:26 CEST 2003


$SUBJECT is attached - useful for stuff like

dvbstream -whatever | mplayer -

and still wanting to control mplayer via -slave commands from a gui

With this patch, you can

mkfifo /tmp/foo
dvbstream -whatever |mplayer -cfifo /tmp/foo -slave -

And write -slave commands to /tmp/foo instead of stdin [which is occupied 
by dvbstream]

LLaP
bero

-- 
Ark Linux - Linux for the masses
http://www.arklinux.org/

Redistribution and processing of this message is subject to
http://www.arklinux.org/terms.php
-------------- next part --------------
--- mplayer/mplayer.c.cfifo	2003-04-07 01:26:58.000000000 +0200
+++ mplayer/mplayer.c	2003-04-07 01:28:58.000000000 +0200
@@ -84,6 +84,8 @@
 int verbose=0;
 int identify=0;
 static int quiet=0;
+char *cmd_fifo=NULL;
+int cmd_fifo_fd=-1;
 
 #define ABS(x) (((x)>=0)?(x):(-(x)))
 #define ROUND(x) ((int)((x)<0 ? (x)-0.5 : (x)+0.5))
@@ -469,6 +471,9 @@
 
   current_module="exit_player";
 
+  if(cmd_fifo_fd>0)
+    close(cmd_fifo_fd);
+
   if(how) mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_Exiting,mp_gettext(how));
   mp_msg(MSGT_CPLAYER,MSGL_DBG2,"max framesize was %d bytes\n",max_framesize);
 
@@ -1044,13 +1049,17 @@
 #else
   mp_input_add_key_fd(-1,0,mplayer_get_key,NULL);
 #endif
+if(cmd_fifo)
+  cmd_fifo_fd = open(cmd_fifo, O_RDONLY|O_NONBLOCK);
+if(cmd_fifo_fd < 0)
+  cmd_fifo_fd = 0;
 if(slave_mode)
-   mp_input_add_cmd_fd(0,1,NULL,NULL);
+   mp_input_add_cmd_fd(cmd_fifo_fd,1,NULL,NULL);
 else if(!use_stdin)
 #ifndef HAVE_NO_POSIX_SELECT
-  mp_input_add_key_fd(0,1,NULL,NULL);
+  mp_input_add_key_fd(cmd_fifo_fd,1,NULL,NULL);
 #else
-  mp_input_add_key_fd(0,0,NULL,NULL);
+  mp_input_add_key_fd(cmd_fifo_fd,0,NULL,NULL);
 #endif
 
 setvbuf(stdin, 0, _IONBF, 0);
--- mplayer/cfg-mplayer.h.cfifo	2003-04-07 01:26:58.000000000 +0200
+++ mplayer/cfg-mplayer.h	2003-04-07 01:26:58.000000000 +0200
@@ -5,6 +5,7 @@
 #include "cfg-common.h"
 
 extern int use_stdin;
+extern char *cmd_fifo;
 
 #if defined(HAVE_FBDEV)||defined(HAVE_VESA)
 extern char *monitor_hfreq_str;
@@ -424,5 +425,7 @@
 	{"-help", help_text, CONF_TYPE_PRINT, CONF_NOCFG|CONF_GLOBAL, 0, 0, NULL},
 	{"help", help_text, CONF_TYPE_PRINT, CONF_NOCFG|CONF_GLOBAL, 0, 0, NULL},
 	{"h", help_text, CONF_TYPE_PRINT, CONF_NOCFG|CONF_GLOBAL, 0, 0, NULL},
+
+	{"cfifo", &cmd_fifo, CONF_TYPE_STRING, CONF_GLOBAL, 0, 0, NULL},
 	{NULL, NULL, 0, 0, 0, 0, NULL}
 };


More information about the MPlayer-users mailing list