[MPlayer-dev-eng] Slave commands output fifo

FoX foxcore at gmail.com
Tue Sep 19 23:12:48 CEST 2006


Hi all,

I'm working on a patch I'd like you to look at.
For the GeeXboX project, we need to retrieve the output of slave
commands with another way than parsing STDOUT.
So here is a patch that adds support for an optional info_fifo
parameter, where ANS_* informations are written.

Happy reviewing and thanks for your time.
-------------- next part --------------
Index: mplayer.c
===================================================================
--- mplayer.c	(revision 19906)
+++ mplayer.c	(working copy)
@@ -295,6 +295,8 @@
 static char *stream_dump_name="stream.dump";
        int stream_dump_type=0;
 
+       char* info_fifo_name=NULL;
+
 // A-V sync:
 static float default_max_pts_correction=-1;//0.01f;
 static float max_pts_correction=0;//default_max_pts_correction;
Index: cfg-mplayer.h
===================================================================
--- cfg-mplayer.h	(revision 19906)
+++ cfg-mplayer.h	(working copy)
@@ -340,6 +340,8 @@
 	{"loop", &loop_times, CONF_TYPE_INT, CONF_RANGE, -1, 10000, NULL},
 	{"playlist", NULL, CONF_TYPE_STRING, 0, 0, 0, NULL},
 
+	{"info_fifo", &info_fifo_name, CONF_TYPE_STRING, 0, 0, 0, NULL},
+
 	// a-v sync stuff:
         {"correct-pts", &correct_pts, CONF_TYPE_FLAG, 0, 0, 1, NULL},
         {"no-correct-pts", &correct_pts, CONF_TYPE_FLAG, 0, 1, 0, NULL},
Index: mp_msg.c
===================================================================
--- mp_msg.c	(revision 19906)
+++ mp_msg.c	(working copy)
@@ -5,6 +5,7 @@
 #include <stdlib.h>
 #include <stdarg.h>
 #include <string.h>
+#include <fcntl.h>
 
 #include "config.h"
 
@@ -38,6 +39,8 @@
 static iconv_t msgiconv;
 #endif
 
+extern char* info_fifo_name;
+
 void mp_msg_init(void){
     int i;
     char *env = getenv("MPLAYER_VERBOSE");
@@ -186,6 +189,16 @@
                  ||tmp[strlen(tmp)-1] == '\r';
     }
 #endif
+    if (info_fifo_name && !strncmp(tmp, "ANS_", 4) ){
+        int fifo_fd = open(info_fifo_name, O_RDWR | O_NONBLOCK);
+        if(fifo_fd >= 0){
+          FILE* info_fifo = fdopen(fifo_fd, "w");
+          if(info_fifo){
+            fprintf(info_fifo, "%s", tmp);
+            fclose(info_fifo);
+         }
+       }
+    }
     if (lev <= MSGL_WARN){
 	fprintf(stderr, "%s", tmp);fflush(stderr);
     } else {


More information about the MPlayer-dev-eng mailing list