#!/bin/sh
fifo=tcp://127.0.0.1:9090
porta=9091
fifoa=tcp://127.0.0.1:$porta
#frame_rate MUST match the encoder framerate
frame_rate=25

f_in=`expr $frame_rate \* 2`
echo 'AUDIO-STREAMING:  starting_audio.sh'
echo 'Cache-Control: no-cache'
echo 'Pragma: no-cache'
echo ''

killall -9 ffmpeg

PROCS=`ps`
n=0
echo $PROCS | grep ffmpeg > /dev/null 2>&1
if [ $? -ne 0 ]; then
	while [ $n -lt 6 ];
	do
		if [ -z "$(netstat -tln 2&> /dev/null | grep $porta)" ];
		then
			n=$(($n+1))
			sleep 1
		else
			ffmpeg -f wav  -i $fifoa -f wav -
			n=6
		fi
	done
fi

