Commit 27d68d8f authored by Max Kellermann's avatar Max Kellermann

output/Internal: move the Mutex to struct AudioOutputControl

struct AudioOutput should not know or care about multi-threading.
parent 546b773b
...@@ -41,8 +41,7 @@ struct notify audio_output_client_notify; ...@@ -41,8 +41,7 @@ struct notify audio_output_client_notify;
AudioOutputControl::AudioOutputControl(AudioOutput *_output, AudioOutputControl::AudioOutputControl(AudioOutput *_output,
AudioOutputClient &_client) AudioOutputClient &_client)
:output(_output), client(_client), :output(_output), client(_client),
thread(BIND_THIS_METHOD(Task)), thread(BIND_THIS_METHOD(Task))
mutex(output->mutex)
{ {
} }
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include "Source.hxx" #include "Source.hxx"
#include "AudioFormat.hxx" #include "AudioFormat.hxx"
#include "thread/Thread.hxx" #include "thread/Thread.hxx"
#include "thread/Mutex.hxx"
#include "thread/Cond.hxx" #include "thread/Cond.hxx"
#include "system/PeriodClock.hxx" #include "system/PeriodClock.hxx"
#include "Compiler.h" #include "Compiler.h"
...@@ -203,7 +204,10 @@ class AudioOutputControl { ...@@ -203,7 +204,10 @@ class AudioOutputControl {
bool skip_delay; bool skip_delay;
public: public:
Mutex &mutex; /**
* This mutex protects #open, #fail_timer, #pipe.
*/
mutable Mutex mutex;
AudioOutputControl(AudioOutput *_output, AudioOutputClient &_client); AudioOutputControl(AudioOutput *_output, AudioOutputClient &_client);
......
...@@ -22,7 +22,6 @@ ...@@ -22,7 +22,6 @@
#include "AudioFormat.hxx" #include "AudioFormat.hxx"
#include "filter/Observer.hxx" #include "filter/Observer.hxx"
#include "thread/Mutex.hxx"
class PreparedFilter; class PreparedFilter;
class MusicPipe; class MusicPipe;
...@@ -107,11 +106,6 @@ struct AudioOutput { ...@@ -107,11 +106,6 @@ struct AudioOutput {
FilterObserver convert_filter; FilterObserver convert_filter;
/** /**
* This mutex protects #open, #fail_timer, #pipe.
*/
mutable Mutex mutex;
/**
* Throws #std::runtime_error on error. * Throws #std::runtime_error on error.
*/ */
AudioOutput(const AudioOutputPlugin &_plugin, AudioOutput(const AudioOutputPlugin &_plugin,
......
...@@ -480,7 +480,7 @@ AudioOutputControl::Task() ...@@ -480,7 +480,7 @@ AudioOutputControl::Task()
if (command == Command::NONE) { if (command == Command::NONE) {
woken_for_play = false; woken_for_play = false;
cond.wait(output->mutex); cond.wait(mutex);
} }
} }
} }
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include "mixer/MixerList.hxx" #include "mixer/MixerList.hxx"
#include "pcm/PcmExport.hxx" #include "pcm/PcmExport.hxx"
#include "system/ByteOrder.hxx" #include "system/ByteOrder.hxx"
#include "thread/Mutex.hxx"
#include "thread/Cond.hxx" #include "thread/Cond.hxx"
#include "util/Manual.hxx" #include "util/Manual.hxx"
#include "util/RuntimeError.hxx" #include "util/RuntimeError.hxx"
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include "AndroidSimpleBufferQueue.hxx" #include "AndroidSimpleBufferQueue.hxx"
#include "../../OutputAPI.hxx" #include "../../OutputAPI.hxx"
#include "../../Wrapper.hxx" #include "../../Wrapper.hxx"
#include "thread/Mutex.hxx"
#include "thread/Cond.hxx" #include "thread/Cond.hxx"
#include "util/Macros.hxx" #include "util/Macros.hxx"
#include "util/Domain.hxx" #include "util/Domain.hxx"
......
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