Commit f86d6b01 authored by Max Kellermann's avatar Max Kellermann

output/Control: move pipe initialization to the OutputThread

Un-protect the SharedPipeConsumer instance, and make it available in the OutputThread only. This gives more well-defined mutex protection.
parent 71c72ed0
...@@ -256,6 +256,11 @@ struct AudioOutput { ...@@ -256,6 +256,11 @@ struct AudioOutput {
* The #AudioFormat requested by #Command::OPEN. * The #AudioFormat requested by #Command::OPEN.
*/ */
AudioFormat audio_format; AudioFormat audio_format;
/**
* The #MusicPipe passed to #Command::OPEN.
*/
const MusicPipe *pipe;
} request; } request;
/** /**
......
...@@ -122,8 +122,7 @@ AudioOutput::Open(const AudioFormat audio_format, const MusicPipe &mp) ...@@ -122,8 +122,7 @@ AudioOutput::Open(const AudioFormat audio_format, const MusicPipe &mp)
} }
request.audio_format = audio_format; request.audio_format = audio_format;
request.pipe = ∓
pipe.Init(mp);
if (!thread.IsDefined()) if (!thread.IsDefined())
StartThread(); StartThread();
......
...@@ -145,6 +145,7 @@ AudioOutput::Open() ...@@ -145,6 +145,7 @@ AudioOutput::Open()
return; return;
in_audio_format = request.audio_format; in_audio_format = request.audio_format;
pipe.Init(*request.pipe);
bool success; bool success;
...@@ -284,8 +285,9 @@ AudioOutput::Reopen() ...@@ -284,8 +285,9 @@ AudioOutput::Reopen()
{ {
assert(open); assert(open);
if (request.audio_format != in_audio_format && if ((request.audio_format != in_audio_format &&
!config_audio_format.IsFullyDefined()) { !config_audio_format.IsFullyDefined()) ||
request.pipe != &pipe.GetPipe()) {
Close(true); Close(true);
Open(); Open();
} else { } else {
......
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