Tnx Robin
ffmpeg also works excellent as decoer.
With   ffmpeg -i /some/file -f u16le  -ar 44100 | myprog ...
i gotta horrable sound. Probably U mean  -f s16le !
 
So, i have rewrited my olde 2-fork mpg123 mixer as 1-fork ffmpeg "frontend"
http://martini.pudele.com/radio/programming/audio/ffmpegdec02.c
fundamentally without any changes, except
 #define PLAYER_BIN "/usr/bin/ffmpeg"
   execlp(PLAYER_BIN,PLAYER_BIN, "-i", mxk.trknamep, "-f", "s16le", "-ar","44100", "-v","0" ,"-", NULL);
 
Any loud output messages i drain out simple with close(2); after fork();
So far everything is OK, if i decode whole files.
 
It seems that ffmpeg during da decoding set terminal in canonical mode.
If i decode only part of file, and kill() em @ middle of decoding,
ffmpeg does not restore normal terminal mode , and i do not see commands which i type.
Then helps (blind typed) command "reset".
I tried send several signals with kill() SIGKILL 2 SIGTSTP SIGQUIT SIGINT 15 ..., 
but none of em has handler for terminal restore.
 
I fixed this behavior with 
#include <termios.h>
struct termios tsave;   /*  ! ! ! F-king ffmpeg ! ! ! */
/* sets canonical input mode */
/*----*/void save_terminal(void)
/*----*/{ struct termios tbuf;
/*----*/  tcgetattr(0,&tbuf);
/*----*/  tsave=tbuf;
/*----*/}
 
/* restore the settings */
/*----*/void restore_terminal(void)
/*----*/{  tcsetattr(0,TCSANOW,&tsave);  }
 
I have tried close(0); where 0=stdin , after fork(); but program has frozen.
 
How do i decouple childs stdin from terminal or redirect em from /dev/null ?
 
 
Tnx in advance @ all
 


That's probably why mplayer devs recommend using mkfifo (named pipe)
instead of stdout.. 'mencoder' can do it.

If you need to support a variety of unknown formats and codecs: ffmpeg
is an alternative and gstreamer might be one.

ffmpeg -i /some/file -f u16le -acodec pcm_s16le -ar 44100 - \
| jack-stdin system:playback_1 system:playback_2

on that note, `jack-stdout` can capture and pipe raw PCM data from any
JACK-application including `mplayer -ao jack /some/file`. YMMV.

HTH,
robin






----