output/Control: add struct AudioOutputControl
Will move attributes from struct AudioOutput that are specific to the OutputThread. The new struct AudioOutputControl is a holder for the AudioOutput pointer. This prepares for making the output list more dynamic, to allow moving outputs to between partitions.
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "Control.hxx"
|
||||
#include "Internal.hxx"
|
||||
#include "OutputPlugin.hxx"
|
||||
#include "Domain.hxx"
|
||||
@@ -36,6 +37,72 @@ static constexpr PeriodClock::Duration REOPEN_AFTER = std::chrono::seconds(10);
|
||||
|
||||
struct notify audio_output_client_notify;
|
||||
|
||||
AudioOutputControl::AudioOutputControl(AudioOutput *_output)
|
||||
:output(_output), mutex(output->mutex)
|
||||
{
|
||||
}
|
||||
|
||||
const char *
|
||||
AudioOutputControl::GetName() const
|
||||
{
|
||||
return output->GetName();
|
||||
}
|
||||
|
||||
AudioOutputClient &
|
||||
AudioOutputControl::GetClient()
|
||||
{
|
||||
return *output->client;
|
||||
}
|
||||
|
||||
Mixer *
|
||||
AudioOutputControl::GetMixer() const
|
||||
{
|
||||
return output->mixer;
|
||||
}
|
||||
|
||||
bool
|
||||
AudioOutputControl::IsEnabled() const
|
||||
{
|
||||
return output->IsEnabled();
|
||||
}
|
||||
|
||||
bool
|
||||
AudioOutputControl::LockSetEnabled(bool new_value)
|
||||
{
|
||||
const std::lock_guard<Mutex> protect(mutex);
|
||||
|
||||
if (new_value == output->enabled)
|
||||
return false;
|
||||
|
||||
output->enabled = new_value;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
AudioOutputControl::LockToggleEnabled()
|
||||
{
|
||||
const std::lock_guard<Mutex> protect(mutex);
|
||||
return output->enabled = !output->enabled;
|
||||
}
|
||||
|
||||
bool
|
||||
AudioOutputControl::IsOpen() const
|
||||
{
|
||||
return output->IsOpen();
|
||||
}
|
||||
|
||||
bool
|
||||
AudioOutputControl::IsBusy() const
|
||||
{
|
||||
return output->IsBusy();
|
||||
}
|
||||
|
||||
const std::exception_ptr &
|
||||
AudioOutputControl::GetLastError() const
|
||||
{
|
||||
return output->GetLastError();
|
||||
}
|
||||
|
||||
void
|
||||
AudioOutput::WaitForCommand()
|
||||
{
|
||||
@@ -46,6 +113,12 @@ AudioOutput::WaitForCommand()
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
AudioOutputControl::WaitForCommand()
|
||||
{
|
||||
output->WaitForCommand();
|
||||
}
|
||||
|
||||
void
|
||||
AudioOutput::CommandAsync(Command cmd)
|
||||
{
|
||||
@@ -104,6 +177,18 @@ AudioOutput::DisableAsync()
|
||||
CommandAsync(Command::DISABLE);
|
||||
}
|
||||
|
||||
void
|
||||
AudioOutputControl::EnableDisableAsync()
|
||||
{
|
||||
output->EnableDisableAsync();
|
||||
}
|
||||
|
||||
void
|
||||
AudioOutputControl::LockPauseAsync()
|
||||
{
|
||||
output->LockPauseAsync();
|
||||
}
|
||||
|
||||
inline bool
|
||||
AudioOutput::Open(const AudioFormat audio_format, const MusicPipe &mp)
|
||||
{
|
||||
@@ -175,6 +260,38 @@ AudioOutput::LockUpdate(const AudioFormat audio_format,
|
||||
return false;
|
||||
}
|
||||
|
||||
void
|
||||
AudioOutputControl::LockRelease()
|
||||
{
|
||||
output->LockRelease();
|
||||
}
|
||||
|
||||
void
|
||||
AudioOutputControl::LockCloseWait()
|
||||
{
|
||||
output->LockCloseWait();
|
||||
}
|
||||
|
||||
bool
|
||||
AudioOutputControl::LockUpdate(const AudioFormat audio_format,
|
||||
const MusicPipe &mp,
|
||||
bool force)
|
||||
{
|
||||
return output->LockUpdate(audio_format, mp, force);
|
||||
}
|
||||
|
||||
bool
|
||||
AudioOutputControl::LockIsChunkConsumed(const MusicChunk &chunk) const
|
||||
{
|
||||
return output->LockIsChunkConsumed(chunk);
|
||||
}
|
||||
|
||||
void
|
||||
AudioOutputControl::ClearTailChunk(const MusicChunk &chunk)
|
||||
{
|
||||
output->ClearTailChunk(chunk);
|
||||
}
|
||||
|
||||
void
|
||||
AudioOutput::LockPlay()
|
||||
{
|
||||
@@ -253,6 +370,12 @@ AudioOutput::LockCloseWait()
|
||||
CloseWait();
|
||||
}
|
||||
|
||||
void
|
||||
AudioOutputControl::SetReplayGainMode(ReplayGainMode _mode)
|
||||
{
|
||||
return output->SetReplayGainMode(_mode);
|
||||
}
|
||||
|
||||
void
|
||||
AudioOutput::StopThread()
|
||||
{
|
||||
@@ -275,6 +398,12 @@ AudioOutput::BeginDestroy()
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
AudioOutputControl::BeginDestroy()
|
||||
{
|
||||
output->BeginDestroy();
|
||||
}
|
||||
|
||||
void
|
||||
AudioOutput::FinishDestroy()
|
||||
{
|
||||
@@ -283,3 +412,34 @@ AudioOutput::FinishDestroy()
|
||||
|
||||
audio_output_free(this);
|
||||
}
|
||||
|
||||
void
|
||||
AudioOutputControl::FinishDestroy()
|
||||
{
|
||||
output->FinishDestroy();
|
||||
output = nullptr;
|
||||
}
|
||||
|
||||
void
|
||||
AudioOutputControl::LockPlay()
|
||||
{
|
||||
output->LockPlay();
|
||||
}
|
||||
|
||||
void
|
||||
AudioOutputControl::LockDrainAsync()
|
||||
{
|
||||
output->LockDrainAsync();
|
||||
}
|
||||
|
||||
void
|
||||
AudioOutputControl::LockCancelAsync()
|
||||
{
|
||||
output->LockCancelAsync();
|
||||
}
|
||||
|
||||
void
|
||||
AudioOutputControl::LockAllowPlay()
|
||||
{
|
||||
output->LockAllowPlay();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user