aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2014-12-24 22:11:57 +0100
committerMax Kellermann <max@duempel.org>2014-12-24 22:18:47 +0100
commitc5409d52f5d4edace90f81585fe0f07da64e0f5d (patch)
tree0b8cc1f2a699ab0cd3e62c2c212ea1e03e73b0a7 /src
parent54fc8f0e8c4ba5bf3eca799eab03201fea099d14 (diff)
downloadmpd-c5409d52f5d4edace90f81585fe0f07da64e0f5d.tar.gz
mpd-c5409d52f5d4edace90f81585fe0f07da64e0f5d.tar.xz
mpd-c5409d52f5d4edace90f81585fe0f07da64e0f5d.zip
output/Internal: move enum AudioOutputCommand into the struct
Diffstat (limited to 'src')
-rw-r--r--src/output/Init.cxx2
-rw-r--r--src/output/Internal.hxx52
-rw-r--r--src/output/OutputControl.cxx26
-rw-r--r--src/output/OutputThread.cxx36
4 files changed, 58 insertions, 58 deletions
diff --git a/src/output/Init.cxx b/src/output/Init.cxx
index fac6bb45e..f9648e0d4 100644
--- a/src/output/Init.cxx
+++ b/src/output/Init.cxx
@@ -58,7 +58,7 @@ AudioOutput::AudioOutput(const AudioOutputPlugin &_plugin)
filter(nullptr),
replay_gain_filter(nullptr),
other_replay_gain_filter(nullptr),
- command(AudioOutputCommand::NONE)
+ command(Command::NONE)
{
assert(plugin.finish != nullptr);
assert(plugin.open != nullptr);
diff --git a/src/output/Internal.hxx b/src/output/Internal.hxx
index 19772b08a..d2ca39585 100644
--- a/src/output/Internal.hxx
+++ b/src/output/Internal.hxx
@@ -40,32 +40,32 @@ struct config_param;
struct PlayerControl;
struct AudioOutputPlugin;
-enum class AudioOutputCommand {
- NONE,
- ENABLE,
- DISABLE,
- OPEN,
+struct AudioOutput {
+ enum class Command {
+ NONE,
+ ENABLE,
+ DISABLE,
+ OPEN,
- /**
- * This command is invoked when the input audio format
- * changes.
- */
- REOPEN,
+ /**
+ * This command is invoked when the input audio format
+ * changes.
+ */
+ REOPEN,
- CLOSE,
- PAUSE,
+ CLOSE,
+ PAUSE,
- /**
- * Drains the internal (hardware) buffers of the device. This
- * operation may take a while to complete.
- */
- DRAIN,
+ /**
+ * Drains the internal (hardware) buffers of the device. This
+ * operation may take a while to complete.
+ */
+ DRAIN,
- CANCEL,
- KILL
-};
+ CANCEL,
+ KILL
+ };
-struct AudioOutput {
/**
* The device's configured display name.
*/
@@ -231,7 +231,7 @@ struct AudioOutput {
/**
* The next command to be performed by the output thread.
*/
- AudioOutputCommand command;
+ Command command;
/**
* The music pipe which provides music chunks to be played.
@@ -284,7 +284,7 @@ struct AudioOutput {
}
bool IsCommandFinished() const {
- return command == AudioOutputCommand::NONE;
+ return command == Command::NONE;
}
/**
@@ -299,7 +299,7 @@ struct AudioOutput {
*
* Caller must lock the mutex.
*/
- void CommandAsync(AudioOutputCommand cmd);
+ void CommandAsync(Command cmd);
/**
* Sends a command to the #AudioOutput object and waits for
@@ -307,13 +307,13 @@ struct AudioOutput {
*
* Caller must lock the mutex.
*/
- void CommandWait(AudioOutputCommand cmd);
+ void CommandWait(Command cmd);
/**
* Lock the #AudioOutput object and execute the command
* synchronously.
*/
- void LockCommandWait(AudioOutputCommand cmd);
+ void LockCommandWait(Command cmd);
/**
* Enables the device.
diff --git a/src/output/OutputControl.cxx b/src/output/OutputControl.cxx
index 473f47bdf..7581d4d58 100644
--- a/src/output/OutputControl.cxx
+++ b/src/output/OutputControl.cxx
@@ -46,7 +46,7 @@ AudioOutput::WaitForCommand()
}
void
-AudioOutput::CommandAsync(AudioOutputCommand cmd)
+AudioOutput::CommandAsync(Command cmd)
{
assert(IsCommandFinished());
@@ -55,14 +55,14 @@ AudioOutput::CommandAsync(AudioOutputCommand cmd)
}
void
-AudioOutput::CommandWait(AudioOutputCommand cmd)
+AudioOutput::CommandWait(Command cmd)
{
CommandAsync(cmd);
WaitForCommand();
}
void
-AudioOutput::LockCommandWait(AudioOutputCommand cmd)
+AudioOutput::LockCommandWait(Command cmd)
{
const ScopeLock protect(mutex);
CommandWait(cmd);
@@ -92,7 +92,7 @@ AudioOutput::LockEnableWait()
StartThread();
}
- LockCommandWait(AudioOutputCommand::ENABLE);
+ LockCommandWait(Command::ENABLE);
}
void
@@ -109,7 +109,7 @@ AudioOutput::LockDisableWait()
return;
}
- LockCommandWait(AudioOutputCommand::DISABLE);
+ LockCommandWait(Command::DISABLE);
}
inline bool
@@ -134,7 +134,7 @@ AudioOutput::Open(const AudioFormat audio_format, const MusicPipe &mp)
/* we're not using audio_output_cancel() here,
because that function is asynchronous */
- CommandWait(AudioOutputCommand::CANCEL);
+ CommandWait(Command::CANCEL);
}
return true;
@@ -149,8 +149,8 @@ AudioOutput::Open(const AudioFormat audio_format, const MusicPipe &mp)
StartThread();
CommandWait(open
- ? AudioOutputCommand::REOPEN
- : AudioOutputCommand::OPEN);
+ ? Command::REOPEN
+ : Command::OPEN);
const bool open2 = open;
if (open2 && mixer != nullptr) {
@@ -174,7 +174,7 @@ AudioOutput::CloseWait()
assert(!open || !fail_timer.IsDefined());
if (open)
- CommandWait(AudioOutputCommand::CLOSE);
+ CommandWait(Command::CLOSE);
else
fail_timer.Reset();
}
@@ -221,7 +221,7 @@ AudioOutput::LockPauseAsync()
assert(allow_play);
if (IsOpen())
- CommandAsync(AudioOutputCommand::PAUSE);
+ CommandAsync(Command::PAUSE);
}
void
@@ -231,7 +231,7 @@ AudioOutput::LockDrainAsync()
assert(allow_play);
if (IsOpen())
- CommandAsync(AudioOutputCommand::DRAIN);
+ CommandAsync(Command::DRAIN);
}
void
@@ -241,7 +241,7 @@ AudioOutput::LockCancelAsync()
if (IsOpen()) {
allow_play = false;
- CommandAsync(AudioOutputCommand::CANCEL);
+ CommandAsync(Command::CANCEL);
}
}
@@ -279,7 +279,7 @@ AudioOutput::StopThread()
assert(thread.IsDefined());
assert(allow_play);
- LockCommandWait(AudioOutputCommand::KILL);
+ LockCommandWait(Command::KILL);
thread.Join();
}
diff --git a/src/output/OutputThread.cxx b/src/output/OutputThread.cxx
index c946ca9aa..eb9277d04 100644
--- a/src/output/OutputThread.cxx
+++ b/src/output/OutputThread.cxx
@@ -45,8 +45,8 @@
void
AudioOutput::CommandFinished()
{
- assert(command != AudioOutputCommand::NONE);
- command = AudioOutputCommand::NONE;
+ assert(command != Command::NONE);
+ command = Command::NONE;
mutex.unlock();
audio_output_client_notify.Signal();
@@ -342,7 +342,7 @@ AudioOutput::WaitForDelay()
(void)cond.timed_wait(mutex, delay);
- if (command != AudioOutputCommand::NONE)
+ if (command != Command::NONE)
return false;
}
}
@@ -471,7 +471,7 @@ AudioOutput::PlayChunk(const MusicChunk *chunk)
Error error;
- while (!data.IsEmpty() && command == AudioOutputCommand::NONE) {
+ while (!data.IsEmpty() && command == Command::NONE) {
if (!WaitForDelay())
break;
@@ -529,7 +529,7 @@ AudioOutput::Play()
assert(!in_playback_loop);
in_playback_loop = true;
- while (chunk != nullptr && command == AudioOutputCommand::NONE) {
+ while (chunk != nullptr && command == Command::NONE) {
assert(!current_chunk_finished);
current_chunk = chunk;
@@ -577,7 +577,7 @@ AudioOutput::Pause()
Close(false);
break;
}
- } while (command == AudioOutputCommand::NONE);
+ } while (command == Command::NONE);
pause = false;
}
@@ -594,30 +594,30 @@ AudioOutput::Task()
while (1) {
switch (command) {
- case AudioOutputCommand::NONE:
+ case Command::NONE:
break;
- case AudioOutputCommand::ENABLE:
+ case Command::ENABLE:
Enable();
CommandFinished();
break;
- case AudioOutputCommand::DISABLE:
+ case Command::DISABLE:
Disable();
CommandFinished();
break;
- case AudioOutputCommand::OPEN:
+ case Command::OPEN:
Open();
CommandFinished();
break;
- case AudioOutputCommand::REOPEN:
+ case Command::REOPEN:
Reopen();
CommandFinished();
break;
- case AudioOutputCommand::CLOSE:
+ case Command::CLOSE:
assert(open);
assert(pipe != nullptr);
@@ -625,7 +625,7 @@ AudioOutput::Task()
CommandFinished();
break;
- case AudioOutputCommand::PAUSE:
+ case Command::PAUSE:
if (!open) {
/* the output has failed after
audio_output_all_pause() has
@@ -642,7 +642,7 @@ AudioOutput::Task()
the new command first */
continue;
- case AudioOutputCommand::DRAIN:
+ case Command::DRAIN:
if (open) {
assert(current_chunk == nullptr);
assert(pipe->Peek() == nullptr);
@@ -655,7 +655,7 @@ AudioOutput::Task()
CommandFinished();
continue;
- case AudioOutputCommand::CANCEL:
+ case Command::CANCEL:
current_chunk = nullptr;
if (open) {
@@ -667,7 +667,7 @@ AudioOutput::Task()
CommandFinished();
continue;
- case AudioOutputCommand::KILL:
+ case Command::KILL:
current_chunk = nullptr;
CommandFinished();
mutex.unlock();
@@ -679,7 +679,7 @@ AudioOutput::Task()
chunks in the pipe */
continue;
- if (command == AudioOutputCommand::NONE) {
+ if (command == Command::NONE) {
woken_for_play = false;
cond.wait(mutex);
}
@@ -696,7 +696,7 @@ AudioOutput::Task(void *arg)
void
AudioOutput::StartThread()
{
- assert(command == AudioOutputCommand::NONE);
+ assert(command == Command::NONE);
Error error;
if (!thread.Start(Task, this, error))