Commit e5c9f6c1 authored by Max Kellermann's avatar Max Kellermann

output/Internal: add attribute request.audio_format

Make in_audio_format accessible only from within the OutputThread, and add a new one for inter-thread communication.
parent 176dc117
......@@ -166,6 +166,8 @@ struct AudioOutput {
/**
* The audio_format in which audio data is received from the
* player thread (which in turn receives it from the decoder).
*
* Only accessible from within the OutputThread.
*/
AudioFormat in_audio_format;
......@@ -247,6 +249,16 @@ struct AudioOutput {
Command command = Command::NONE;
/**
* Additional data for #command. Protected by #mutex.
*/
struct Request {
/**
* The #AudioFormat requested by #Command::OPEN.
*/
AudioFormat audio_format;
} request;
/**
* This mutex protects #open, #fail_timer, #pipe.
*/
Mutex mutex;
......
......@@ -112,7 +112,7 @@ AudioOutput::Open(const AudioFormat audio_format, const MusicPipe &mp)
fail_timer.Reset();
if (open && audio_format == in_audio_format) {
if (open && audio_format == request.audio_format) {
assert(&pipe.GetPipe() == &mp || (always_on && pause));
if (pause) {
......@@ -131,7 +131,7 @@ AudioOutput::Open(const AudioFormat audio_format, const MusicPipe &mp)
return true;
}
in_audio_format = audio_format;
request.audio_format = audio_format;
pipe.Init(mp);
......
......@@ -134,7 +134,7 @@ inline void
AudioOutput::Open()
{
assert(!open);
assert(in_audio_format.IsValid());
assert(request.audio_format.IsValid());
fail_timer.Reset();
......@@ -144,6 +144,8 @@ AudioOutput::Open()
/* still no luck */
return;
in_audio_format = request.audio_format;
bool success;
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment