[MPlayer-dev-eng] Re: Slave Mode

Dave Lambley mplayer-dev-eng at dlambley.freeserve.co.uk
Sun Oct 19 17:18:19 CEST 2003


Hi,

On Sun, 2003-10-19 at 03:01, Ben Nemec wrote:
> Thanks, that helped a lot.  Unfortunately, after I got that working I
> realized that I need two-way communication with mplayer.  Is there any way
> to do that with popen (I don't think so, but just in case), or what is the
> best way to do it.  I've seen something about a c++ class called pipestream,
> but I can't find it anywhere on my computer or for download.  I've also
> tried using pipe() and fork(), but I haven't been able to get it to work
> even one way, and I'm not positive it can even be used for two-way
> communication.  Thanks for your patience with me on this.

FreeBSD's popen lets you do this. On anything else, you have to do the
fork manually. Something like...

int read_fds[2];
int write_fds[2];

pipe(read_fds);
pipe(write_fds);

if (fork()==0) {
	dup2(0, read_fds[0]);
	dup2(1, write_fds[1]);
	execve("/usr/local/bin/mplayer", ..... );
}

read(write_fds[0], ...);
write(read_fds[1], ...);


You should check the return codes from the calls too.

HTH,
Dave




More information about the MPlayer-dev-eng mailing list