output/Internal: move the Mutex to struct AudioOutputControl

struct AudioOutput should not know or care about multi-threading.
This commit is contained in:
Max Kellermann 2017-06-08 22:23:26 +02:00
parent 546b773b21
commit 27d68d8fdd
6 changed files with 9 additions and 10 deletions

View File

@ -41,8 +41,7 @@ struct notify audio_output_client_notify;
AudioOutputControl::AudioOutputControl(AudioOutput *_output,
AudioOutputClient &_client)
:output(_output), client(_client),
thread(BIND_THIS_METHOD(Task)),
mutex(output->mutex)
thread(BIND_THIS_METHOD(Task))
{
}

View File

@ -23,6 +23,7 @@
#include "Source.hxx"
#include "AudioFormat.hxx"
#include "thread/Thread.hxx"
#include "thread/Mutex.hxx"
#include "thread/Cond.hxx"
#include "system/PeriodClock.hxx"
#include "Compiler.h"
@ -203,7 +204,10 @@ class AudioOutputControl {
bool skip_delay;
public:
Mutex &mutex;
/**
* This mutex protects #open, #fail_timer, #pipe.
*/
mutable Mutex mutex;
AudioOutputControl(AudioOutput *_output, AudioOutputClient &_client);

View File

@ -22,7 +22,6 @@
#include "AudioFormat.hxx"
#include "filter/Observer.hxx"
#include "thread/Mutex.hxx"
class PreparedFilter;
class MusicPipe;
@ -106,11 +105,6 @@ struct AudioOutput {
*/
FilterObserver convert_filter;
/**
* This mutex protects #open, #fail_timer, #pipe.
*/
mutable Mutex mutex;
/**
* Throws #std::runtime_error on error.
*/

View File

@ -480,7 +480,7 @@ AudioOutputControl::Task()
if (command == Command::NONE) {
woken_for_play = false;
cond.wait(output->mutex);
cond.wait(mutex);
}
}
}

View File

@ -26,6 +26,7 @@
#include "mixer/MixerList.hxx"
#include "pcm/PcmExport.hxx"
#include "system/ByteOrder.hxx"
#include "thread/Mutex.hxx"
#include "thread/Cond.hxx"
#include "util/Manual.hxx"
#include "util/RuntimeError.hxx"

View File

@ -25,6 +25,7 @@
#include "AndroidSimpleBufferQueue.hxx"
#include "../../OutputAPI.hxx"
#include "../../Wrapper.hxx"
#include "thread/Mutex.hxx"
#include "thread/Cond.hxx"
#include "util/Macros.hxx"
#include "util/Domain.hxx"