[MPlayer-dev-eng] mplayer slave mode question

Rich Felker dalias at aerifal.cx
Tue Aug 28 18:00:26 CEST 2007


On Mon, Aug 27, 2007 at 05:45:17PM -0500, Kevron Rees wrote:
> From my experience, I can successfully pipe commands to mplayer through
> mplayer's stdin.  I can also create a pipe from mplayer's stdout but
> whenever I retrieve info from mplayer via that fd, I get blocking and my
> program locks up.  I haven't found any code that has two way
> communication with mplayer.  Most frontends just seem to issue system()
> commands or a single popen("mplayer", "w") pipe.
> 
> To work around this problem, I want to be able to pipe mplayer's stdout
> to a file in which I can just purge anytime I want new data.  However, I
> don't know how I can do this.  Mplayer doesn't have a -stdout=foo.txt
> does it?

The question is about your programming language, not MPlayer, but the
short answer is that you need to dump popen() (which creates nasty
FILE* that can't really be used for anything interactive) and use the
pipe() syscall directly, along with fork(), exec*(), and some sort of
non-blocking read (either set the file descriptors from pipe() to
nonblocking mode in the parent process, or use select() to decide when
to read).

Hope this helps!

Rich



More information about the MPlayer-dev-eng mailing list