2009-03-13 18:43:16 +01:00
|
|
|
/*
|
2017-01-03 20:48:59 +01:00
|
|
|
* Copyright 2003-2017 The Music Player Daemon Project
|
2009-03-13 18:43:16 +01:00
|
|
|
* http://www.musicpd.org
|
2008-09-09 10:02:34 +02:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
2009-03-13 18:43:16 +01:00
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
2008-09-09 10:02:34 +02:00
|
|
|
*/
|
|
|
|
|
2009-11-12 09:12:38 +01:00
|
|
|
#include "config.h"
|
2017-02-27 22:55:20 +01:00
|
|
|
#include "Control.hxx"
|
2017-08-07 21:50:13 +02:00
|
|
|
#include "Filtered.hxx"
|
2014-01-28 11:42:54 +01:00
|
|
|
#include "Domain.hxx"
|
2014-01-24 16:25:21 +01:00
|
|
|
#include "mixer/MixerControl.hxx"
|
2013-01-10 10:44:04 +01:00
|
|
|
#include "notify.hxx"
|
2014-01-24 16:31:52 +01:00
|
|
|
#include "filter/plugins/ReplayGainFilterPlugin.hxx"
|
2017-05-22 23:40:20 +02:00
|
|
|
#include "config/Block.hxx"
|
2013-09-27 22:31:24 +02:00
|
|
|
#include "Log.hxx"
|
2008-09-24 07:20:26 +02:00
|
|
|
|
2016-09-09 12:52:51 +02:00
|
|
|
#include <stdexcept>
|
|
|
|
|
2008-10-08 10:49:29 +02:00
|
|
|
#include <assert.h>
|
2008-09-24 07:20:26 +02:00
|
|
|
|
2016-12-27 22:47:20 +01:00
|
|
|
/** after a failure, wait this duration before
|
2013-10-20 13:52:26 +02:00
|
|
|
automatically reopening the device */
|
2016-12-27 22:47:20 +01:00
|
|
|
static constexpr PeriodClock::Duration REOPEN_AFTER = std::chrono::seconds(10);
|
2009-02-28 20:43:23 +01:00
|
|
|
|
2008-12-27 20:53:52 +01:00
|
|
|
struct notify audio_output_client_notify;
|
2008-09-24 07:20:26 +02:00
|
|
|
|
2017-08-07 18:47:39 +02:00
|
|
|
AudioOutputControl::AudioOutputControl(FilteredAudioOutput *_output,
|
2017-05-23 00:31:13 +02:00
|
|
|
AudioOutputClient &_client)
|
|
|
|
:output(_output), client(_client),
|
2017-06-08 22:23:26 +02:00
|
|
|
thread(BIND_THIS_METHOD(Task))
|
2017-02-27 22:55:20 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2017-05-22 23:36:45 +02:00
|
|
|
void
|
|
|
|
AudioOutputControl::Configure(const ConfigBlock &block)
|
|
|
|
{
|
2017-05-22 23:40:20 +02:00
|
|
|
tags = block.GetBlockValue("tags", true);
|
|
|
|
always_on = block.GetBlockValue("always_on", false);
|
|
|
|
enabled = block.GetBlockValue("enabled", true);
|
2017-05-22 23:36:45 +02:00
|
|
|
}
|
|
|
|
|
2017-02-27 22:55:20 +01:00
|
|
|
const char *
|
2017-05-23 00:17:23 +02:00
|
|
|
AudioOutputControl::GetName() const noexcept
|
2017-02-27 22:55:20 +01:00
|
|
|
{
|
|
|
|
return output->GetName();
|
|
|
|
}
|
|
|
|
|
2017-12-19 10:36:32 +01:00
|
|
|
const char *
|
|
|
|
AudioOutputControl::GetPluginName() const noexcept
|
|
|
|
{
|
|
|
|
return output->GetPluginName();
|
|
|
|
}
|
|
|
|
|
2017-08-08 14:02:58 +02:00
|
|
|
const char *
|
|
|
|
AudioOutputControl::GetLogName() const noexcept
|
|
|
|
{
|
|
|
|
return output->GetLogName();
|
|
|
|
}
|
|
|
|
|
2017-02-27 22:55:20 +01:00
|
|
|
Mixer *
|
2017-05-23 00:17:23 +02:00
|
|
|
AudioOutputControl::GetMixer() const noexcept
|
2017-02-27 22:55:20 +01:00
|
|
|
{
|
|
|
|
return output->mixer;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2017-05-23 00:17:23 +02:00
|
|
|
AudioOutputControl::LockSetEnabled(bool new_value) noexcept
|
2017-02-27 22:55:20 +01:00
|
|
|
{
|
|
|
|
const std::lock_guard<Mutex> protect(mutex);
|
|
|
|
|
2017-05-22 23:40:20 +02:00
|
|
|
if (new_value == enabled)
|
2017-02-27 22:55:20 +01:00
|
|
|
return false;
|
|
|
|
|
2017-05-22 23:40:20 +02:00
|
|
|
enabled = new_value;
|
2017-02-27 22:55:20 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2017-05-23 00:17:23 +02:00
|
|
|
AudioOutputControl::LockToggleEnabled() noexcept
|
2017-02-27 22:55:20 +01:00
|
|
|
{
|
|
|
|
const std::lock_guard<Mutex> protect(mutex);
|
2017-05-22 23:40:20 +02:00
|
|
|
return enabled = !enabled;
|
2017-02-27 22:55:20 +01:00
|
|
|
}
|
|
|
|
|
2014-01-28 11:39:12 +01:00
|
|
|
void
|
2017-05-23 00:17:23 +02:00
|
|
|
AudioOutputControl::WaitForCommand() noexcept
|
2008-09-24 07:20:26 +02:00
|
|
|
{
|
2014-01-28 11:39:12 +01:00
|
|
|
while (!IsCommandFinished()) {
|
|
|
|
mutex.unlock();
|
2013-01-10 10:44:04 +01:00
|
|
|
audio_output_client_notify.Wait();
|
2014-01-28 11:39:12 +01:00
|
|
|
mutex.lock();
|
2008-09-24 07:20:26 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-02-27 22:55:20 +01:00
|
|
|
void
|
2017-05-23 00:17:23 +02:00
|
|
|
AudioOutputControl::CommandAsync(Command cmd) noexcept
|
2008-09-24 07:20:26 +02:00
|
|
|
{
|
2014-01-28 11:39:12 +01:00
|
|
|
assert(IsCommandFinished());
|
|
|
|
|
|
|
|
command = cmd;
|
|
|
|
cond.signal();
|
2008-09-24 07:20:26 +02:00
|
|
|
}
|
2008-09-09 10:02:34 +02:00
|
|
|
|
2014-01-28 11:39:12 +01:00
|
|
|
void
|
2017-05-23 00:17:23 +02:00
|
|
|
AudioOutputControl::CommandWait(Command cmd) noexcept
|
2008-09-24 07:23:19 +02:00
|
|
|
{
|
2014-01-28 11:39:12 +01:00
|
|
|
CommandAsync(cmd);
|
|
|
|
WaitForCommand();
|
2008-09-24 07:23:19 +02:00
|
|
|
}
|
|
|
|
|
2014-01-28 11:39:12 +01:00
|
|
|
void
|
2017-05-23 00:17:23 +02:00
|
|
|
AudioOutputControl::LockCommandWait(Command cmd) noexcept
|
2011-01-10 21:54:43 +01:00
|
|
|
{
|
2017-01-03 07:11:57 +01:00
|
|
|
const std::lock_guard<Mutex> protect(mutex);
|
2014-01-28 11:39:12 +01:00
|
|
|
CommandWait(cmd);
|
2011-01-10 21:54:43 +01:00
|
|
|
}
|
|
|
|
|
2009-10-23 10:55:52 +02:00
|
|
|
void
|
2017-04-28 21:45:47 +02:00
|
|
|
AudioOutputControl::EnableAsync()
|
2009-10-23 10:55:52 +02:00
|
|
|
{
|
2014-01-28 11:39:12 +01:00
|
|
|
if (!thread.IsDefined()) {
|
2017-08-08 15:54:49 +02:00
|
|
|
if (!output->SupportsEnableDisable()) {
|
2009-10-23 10:55:52 +02:00
|
|
|
/* don't bother to start the thread now if the
|
|
|
|
device doesn't even have a enable() method;
|
|
|
|
just assign the variable and we're done */
|
2017-06-08 09:49:30 +02:00
|
|
|
really_enabled = true;
|
2009-10-23 10:55:52 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-01-28 11:39:12 +01:00
|
|
|
StartThread();
|
2009-10-23 10:55:52 +02:00
|
|
|
}
|
|
|
|
|
2016-12-14 08:41:22 +01:00
|
|
|
CommandAsync(Command::ENABLE);
|
2009-10-23 10:55:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2017-05-23 00:17:23 +02:00
|
|
|
AudioOutputControl::DisableAsync() noexcept
|
2009-10-23 10:55:52 +02:00
|
|
|
{
|
2014-01-28 11:39:12 +01:00
|
|
|
if (!thread.IsDefined()) {
|
2017-08-08 15:54:49 +02:00
|
|
|
if (!output->SupportsEnableDisable())
|
2017-06-08 09:49:30 +02:00
|
|
|
really_enabled = false;
|
2009-10-23 10:55:52 +02:00
|
|
|
else
|
|
|
|
/* if there's no thread yet, the device cannot
|
|
|
|
be enabled */
|
2017-06-08 09:49:30 +02:00
|
|
|
assert(!really_enabled);
|
2009-10-23 10:55:52 +02:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-12-14 08:41:22 +01:00
|
|
|
CommandAsync(Command::DISABLE);
|
2009-10-23 10:55:52 +02:00
|
|
|
}
|
|
|
|
|
2017-02-27 22:55:20 +01:00
|
|
|
void
|
|
|
|
AudioOutputControl::EnableDisableAsync()
|
|
|
|
{
|
2017-06-08 09:49:30 +02:00
|
|
|
if (enabled == really_enabled)
|
2017-04-28 21:45:47 +02:00
|
|
|
return;
|
2017-02-27 22:55:20 +01:00
|
|
|
|
2017-05-22 23:40:20 +02:00
|
|
|
if (enabled)
|
2017-04-28 21:45:47 +02:00
|
|
|
EnableAsync();
|
|
|
|
else
|
|
|
|
DisableAsync();
|
2017-02-27 22:55:20 +01:00
|
|
|
}
|
|
|
|
|
2014-01-28 11:39:12 +01:00
|
|
|
inline bool
|
2017-05-23 00:17:23 +02:00
|
|
|
AudioOutputControl::Open(const AudioFormat audio_format,
|
|
|
|
const MusicPipe &mp) noexcept
|
2008-09-09 10:02:34 +02:00
|
|
|
{
|
2014-01-28 11:39:12 +01:00
|
|
|
assert(allow_play);
|
2013-08-03 21:00:50 +02:00
|
|
|
assert(audio_format.IsValid());
|
2009-03-09 19:25:26 +01:00
|
|
|
|
2014-01-28 11:39:12 +01:00
|
|
|
fail_timer.Reset();
|
2008-10-29 22:32:50 +01:00
|
|
|
|
2017-06-08 22:25:45 +02:00
|
|
|
if (open && audio_format == request.audio_format) {
|
2017-05-23 00:00:00 +02:00
|
|
|
assert(request.pipe == &mp || (always_on && pause));
|
2009-03-09 19:25:26 +01:00
|
|
|
|
2017-05-23 00:00:00 +02:00
|
|
|
if (!pause)
|
2016-12-21 13:01:38 +01:00
|
|
|
/* already open, already the right parameters
|
|
|
|
- nothing needs to be done */
|
|
|
|
return true;
|
2008-09-09 10:02:34 +02:00
|
|
|
}
|
|
|
|
|
2016-12-21 17:00:29 +01:00
|
|
|
request.audio_format = audio_format;
|
2016-12-20 23:19:12 +01:00
|
|
|
request.pipe = ∓
|
2009-03-09 19:25:26 +01:00
|
|
|
|
2017-10-30 08:39:44 +01:00
|
|
|
if (!thread.IsDefined()) {
|
|
|
|
try {
|
|
|
|
StartThread();
|
|
|
|
} catch (...) {
|
|
|
|
LogError(std::current_exception());
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2008-09-09 10:02:34 +02:00
|
|
|
|
2016-12-13 20:07:00 +01:00
|
|
|
CommandWait(Command::OPEN);
|
2017-06-08 22:25:45 +02:00
|
|
|
const bool open2 = open;
|
2008-09-09 10:02:34 +02:00
|
|
|
|
2017-04-28 21:45:47 +02:00
|
|
|
if (open2 && output->mixer != nullptr) {
|
2016-09-09 12:52:51 +02:00
|
|
|
try {
|
2017-04-28 21:45:47 +02:00
|
|
|
mixer_open(output->mixer);
|
2017-12-19 10:56:23 +01:00
|
|
|
} catch (...) {
|
|
|
|
FormatError(std::current_exception(),
|
|
|
|
"Failed to open mixer for '%s'",
|
2017-04-28 21:45:47 +02:00
|
|
|
GetName());
|
2016-09-09 12:52:51 +02:00
|
|
|
}
|
2009-10-20 22:10:56 +02:00
|
|
|
}
|
2009-03-26 18:23:23 +01:00
|
|
|
|
2014-01-28 11:39:12 +01:00
|
|
|
return open2;
|
2008-09-09 10:02:34 +02:00
|
|
|
}
|
|
|
|
|
2014-01-28 11:39:12 +01:00
|
|
|
void
|
2017-05-23 00:17:23 +02:00
|
|
|
AudioOutputControl::CloseWait() noexcept
|
2009-10-29 22:39:42 +01:00
|
|
|
{
|
2014-01-28 11:39:12 +01:00
|
|
|
assert(allow_play);
|
2010-11-07 15:30:18 +01:00
|
|
|
|
2017-04-28 21:45:47 +02:00
|
|
|
if (output->mixer != nullptr)
|
|
|
|
mixer_auto_close(output->mixer);
|
2009-10-29 22:39:42 +01:00
|
|
|
|
2017-06-08 22:25:45 +02:00
|
|
|
assert(!open || !fail_timer.IsDefined());
|
2009-10-29 22:39:42 +01:00
|
|
|
|
2017-06-08 22:25:45 +02:00
|
|
|
if (open)
|
2014-12-24 22:11:57 +01:00
|
|
|
CommandWait(Command::CLOSE);
|
2013-11-24 20:20:57 +01:00
|
|
|
else
|
2014-01-28 11:39:12 +01:00
|
|
|
fail_timer.Reset();
|
2009-10-29 22:39:42 +01:00
|
|
|
}
|
|
|
|
|
2009-03-07 19:55:57 +01:00
|
|
|
bool
|
2017-04-28 21:45:47 +02:00
|
|
|
AudioOutputControl::LockUpdate(const AudioFormat audio_format,
|
|
|
|
const MusicPipe &mp,
|
2017-05-23 00:17:23 +02:00
|
|
|
bool force) noexcept
|
2008-10-29 22:17:44 +01:00
|
|
|
{
|
2017-01-03 07:11:57 +01:00
|
|
|
const std::lock_guard<Mutex> protect(mutex);
|
2009-10-29 17:06:40 +01:00
|
|
|
|
2017-06-08 09:49:30 +02:00
|
|
|
if (enabled && really_enabled) {
|
2016-12-29 23:20:26 +01:00
|
|
|
if (force || !fail_timer.IsDefined() ||
|
2015-06-20 15:37:19 +02:00
|
|
|
fail_timer.Check(REOPEN_AFTER * 1000)) {
|
2014-01-28 11:39:12 +01:00
|
|
|
return Open(audio_format, mp);
|
2009-10-29 17:06:40 +01:00
|
|
|
}
|
2014-01-28 11:39:12 +01:00
|
|
|
} else if (IsOpen())
|
|
|
|
CloseWait();
|
2009-03-07 19:55:57 +01:00
|
|
|
|
|
|
|
return false;
|
2008-10-29 22:17:44 +01:00
|
|
|
}
|
|
|
|
|
2017-02-27 22:55:20 +01:00
|
|
|
bool
|
2017-05-23 00:03:06 +02:00
|
|
|
AudioOutputControl::IsChunkConsumed(const MusicChunk &chunk) const noexcept
|
2017-02-27 22:55:20 +01:00
|
|
|
{
|
2017-06-08 22:25:45 +02:00
|
|
|
if (!open)
|
2017-05-23 00:03:06 +02:00
|
|
|
return true;
|
|
|
|
|
|
|
|
return source.IsChunkConsumed(chunk);
|
2017-02-27 22:55:20 +01:00
|
|
|
}
|
|
|
|
|
2017-05-23 00:03:06 +02:00
|
|
|
bool
|
|
|
|
AudioOutputControl::LockIsChunkConsumed(const MusicChunk &chunk) const noexcept
|
2017-02-27 22:55:20 +01:00
|
|
|
{
|
2017-05-23 00:03:06 +02:00
|
|
|
const std::lock_guard<Mutex> protect(mutex);
|
|
|
|
return IsChunkConsumed(chunk);
|
2017-02-27 22:55:20 +01:00
|
|
|
}
|
|
|
|
|
2009-02-16 00:43:06 +01:00
|
|
|
void
|
2017-05-23 00:17:23 +02:00
|
|
|
AudioOutputControl::LockPlay() noexcept
|
2008-09-09 10:02:34 +02:00
|
|
|
{
|
2017-01-03 07:11:57 +01:00
|
|
|
const std::lock_guard<Mutex> protect(mutex);
|
2008-09-09 10:02:34 +02:00
|
|
|
|
2014-01-28 11:39:12 +01:00
|
|
|
assert(allow_play);
|
2011-09-01 07:13:21 +02:00
|
|
|
|
2014-01-28 11:39:12 +01:00
|
|
|
if (IsOpen() && !in_playback_loop && !woken_for_play) {
|
|
|
|
woken_for_play = true;
|
|
|
|
cond.signal();
|
2013-11-06 23:47:30 +01:00
|
|
|
}
|
2008-09-09 10:02:34 +02:00
|
|
|
}
|
|
|
|
|
2014-01-28 11:39:12 +01:00
|
|
|
void
|
2017-05-23 00:17:23 +02:00
|
|
|
AudioOutputControl::LockPauseAsync() noexcept
|
2008-09-29 16:43:55 +02:00
|
|
|
{
|
2017-08-08 15:54:49 +02:00
|
|
|
if (output->mixer != nullptr && !output->SupportsPause())
|
2009-04-21 22:17:52 +02:00
|
|
|
/* the device has no pause mode: close the mixer,
|
|
|
|
unless its "global" flag is set (checked by
|
|
|
|
mixer_auto_close()) */
|
2017-04-28 21:45:47 +02:00
|
|
|
mixer_auto_close(output->mixer);
|
2009-04-21 22:17:52 +02:00
|
|
|
|
2017-01-03 07:11:57 +01:00
|
|
|
const std::lock_guard<Mutex> protect(mutex);
|
2013-04-17 01:19:25 +02:00
|
|
|
|
2014-01-28 11:39:12 +01:00
|
|
|
assert(allow_play);
|
|
|
|
if (IsOpen())
|
2014-12-24 22:11:57 +01:00
|
|
|
CommandAsync(Command::PAUSE);
|
2008-09-29 16:43:55 +02:00
|
|
|
}
|
|
|
|
|
2009-11-09 22:16:26 +01:00
|
|
|
void
|
2017-05-23 00:17:23 +02:00
|
|
|
AudioOutputControl::LockDrainAsync() noexcept
|
2009-11-09 22:16:26 +01:00
|
|
|
{
|
2017-01-03 07:11:57 +01:00
|
|
|
const std::lock_guard<Mutex> protect(mutex);
|
2013-04-17 01:19:25 +02:00
|
|
|
|
2014-01-28 11:39:12 +01:00
|
|
|
assert(allow_play);
|
|
|
|
if (IsOpen())
|
2014-12-24 22:11:57 +01:00
|
|
|
CommandAsync(Command::DRAIN);
|
2009-11-09 22:16:26 +01:00
|
|
|
}
|
|
|
|
|
2014-01-28 11:39:12 +01:00
|
|
|
void
|
2017-05-23 00:17:23 +02:00
|
|
|
AudioOutputControl::LockCancelAsync() noexcept
|
2008-09-09 10:02:34 +02:00
|
|
|
{
|
2017-01-03 07:11:57 +01:00
|
|
|
const std::lock_guard<Mutex> protect(mutex);
|
2011-09-01 07:13:21 +02:00
|
|
|
|
2014-01-28 11:39:12 +01:00
|
|
|
if (IsOpen()) {
|
|
|
|
allow_play = false;
|
2014-12-24 22:11:57 +01:00
|
|
|
CommandAsync(Command::CANCEL);
|
2011-09-01 07:13:21 +02:00
|
|
|
}
|
2011-09-01 07:53:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2017-05-23 00:17:23 +02:00
|
|
|
AudioOutputControl::LockAllowPlay() noexcept
|
2011-09-01 07:53:42 +02:00
|
|
|
{
|
2017-01-03 07:11:57 +01:00
|
|
|
const std::lock_guard<Mutex> protect(mutex);
|
2011-09-01 07:53:42 +02:00
|
|
|
|
2014-01-28 11:39:12 +01:00
|
|
|
allow_play = true;
|
|
|
|
if (IsOpen())
|
|
|
|
cond.signal();
|
2008-09-09 10:02:34 +02:00
|
|
|
}
|
|
|
|
|
2010-03-03 20:29:33 +01:00
|
|
|
void
|
2017-05-23 00:17:23 +02:00
|
|
|
AudioOutputControl::LockRelease() noexcept
|
2010-03-03 20:29:33 +01:00
|
|
|
{
|
2017-05-22 23:40:20 +02:00
|
|
|
if (always_on)
|
2014-01-28 11:39:12 +01:00
|
|
|
LockPauseAsync();
|
2010-03-03 20:29:33 +01:00
|
|
|
else
|
2014-01-28 11:39:12 +01:00
|
|
|
LockCloseWait();
|
2010-03-03 20:29:33 +01:00
|
|
|
}
|
|
|
|
|
2014-01-28 11:39:12 +01:00
|
|
|
void
|
2017-05-23 00:17:23 +02:00
|
|
|
AudioOutputControl::LockCloseWait() noexcept
|
2010-11-04 21:51:02 +01:00
|
|
|
{
|
2017-06-08 22:25:45 +02:00
|
|
|
assert(!open || !fail_timer.IsDefined());
|
2010-11-04 21:51:02 +01:00
|
|
|
|
2017-01-03 07:11:57 +01:00
|
|
|
const std::lock_guard<Mutex> protect(mutex);
|
2014-01-28 11:39:12 +01:00
|
|
|
CloseWait();
|
2010-11-04 21:51:02 +01:00
|
|
|
}
|
|
|
|
|
2014-01-28 11:39:12 +01:00
|
|
|
void
|
2017-05-23 00:17:23 +02:00
|
|
|
AudioOutputControl::StopThread() noexcept
|
2008-09-09 10:02:34 +02:00
|
|
|
{
|
2014-01-28 11:39:12 +01:00
|
|
|
assert(thread.IsDefined());
|
|
|
|
assert(allow_play);
|
2009-01-07 23:55:13 +01:00
|
|
|
|
2014-12-24 22:11:57 +01:00
|
|
|
LockCommandWait(Command::KILL);
|
2014-01-28 11:39:12 +01:00
|
|
|
thread.Join();
|
|
|
|
}
|
2009-02-28 20:43:23 +01:00
|
|
|
|
2017-02-27 22:55:20 +01:00
|
|
|
void
|
2017-05-23 00:17:23 +02:00
|
|
|
AudioOutputControl::BeginDestroy() noexcept
|
2017-02-27 22:55:20 +01:00
|
|
|
{
|
|
|
|
output->BeginDestroy();
|
2017-04-28 21:45:47 +02:00
|
|
|
|
|
|
|
if (thread.IsDefined()) {
|
|
|
|
const std::lock_guard<Mutex> protect(mutex);
|
|
|
|
CommandAsync(Command::KILL);
|
|
|
|
}
|
2017-02-27 22:55:20 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2017-05-23 00:17:23 +02:00
|
|
|
AudioOutputControl::FinishDestroy() noexcept
|
2017-02-27 22:55:20 +01:00
|
|
|
{
|
2017-04-28 21:45:47 +02:00
|
|
|
if (thread.IsDefined())
|
|
|
|
thread.Join();
|
|
|
|
|
2017-02-27 22:55:20 +01:00
|
|
|
output->FinishDestroy();
|
|
|
|
output = nullptr;
|
|
|
|
}
|