mpd2sc: rework setting the halt flag

Commit 05be6a1 refactored reading from the pipe to detect when the
Sender should set the halt flag in the audio message so the Receivers
can detect that the continous audio stream is paused.

The way the commit detects when to set the halt flag has a drawback: it
depends on the audio producer to not write any data to the pipe after a
"stop" command was send to the user command handler. If the producer,
e.g. arecord reading from an audio input, is still writing to the pipe,
a "stop" command will not pause the audio stream, which is quite
unfortunate and not the expected behaviour.

Therefore, do not depend on the audio producer, but open and close the
audio reader. This way, when issueing the "stop" command, the audio
reader is closed and no more data are read.

When the timer expires after the audio reader was closed, it will send a
last audio message with the halt flag set, and will not fire again. The
audio stream is paused until the "play" command is issued again.

Jörg Krause Jörg Krause 2017-11-16

changed mpd2src/audioreader.h
changed mpd2src/fiforeader.cpp
changed mpd2src/fiforeader.h
changed mpd2src/mpd2sc.cpp
changed mpd2src/wavreader.cpp
changed mpd2src/wavreader.h
mpd2src/audioreader.h Diff Switch to side-by-side view
Loading...
mpd2src/fiforeader.cpp Diff Switch to side-by-side view
Loading...
mpd2src/fiforeader.h Diff Switch to side-by-side view
Loading...
mpd2src/mpd2sc.cpp Diff Switch to side-by-side view
Loading...
mpd2src/wavreader.cpp Diff Switch to side-by-side view
Loading...
mpd2src/wavreader.h Diff Switch to side-by-side view
Loading...