2014-01-27 08:20:25 +01:00
|
|
|
/*
|
2017-01-03 20:48:59 +01:00
|
|
|
* Copyright 2003-2017 The Music Player Daemon Project
|
2014-01-27 08:20:25 +01:00
|
|
|
* http://www.musicpd.org
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
#include "MultipleOutputs.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-27 08:20:25 +01:00
|
|
|
#include "MusicBuffer.hxx"
|
|
|
|
#include "MusicPipe.hxx"
|
|
|
|
#include "MusicChunk.hxx"
|
2015-01-21 22:13:44 +01:00
|
|
|
#include "config/Block.hxx"
|
2014-01-27 08:20:25 +01:00
|
|
|
#include "config/ConfigGlobal.hxx"
|
|
|
|
#include "config/ConfigOption.hxx"
|
|
|
|
#include "notify.hxx"
|
2016-11-24 14:04:40 +01:00
|
|
|
#include "util/RuntimeError.hxx"
|
2014-01-27 08:20:25 +01:00
|
|
|
|
2016-10-28 21:11:52 +02:00
|
|
|
#include <stdexcept>
|
|
|
|
|
2014-01-27 08:20:25 +01:00
|
|
|
#include <assert.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
2017-12-29 16:29:49 +01:00
|
|
|
MultipleOutputs::MultipleOutputs(MixerListener &_mixer_listener) noexcept
|
2016-04-21 13:27:45 +02:00
|
|
|
:mixer_listener(_mixer_listener)
|
2014-01-27 08:20:25 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2017-12-29 16:29:49 +01:00
|
|
|
MultipleOutputs::~MultipleOutputs() noexcept
|
2014-01-27 08:20:25 +01:00
|
|
|
{
|
2016-12-14 08:15:33 +01:00
|
|
|
/* parallel destruction */
|
2017-02-27 22:55:20 +01:00
|
|
|
for (auto *i : outputs)
|
2016-12-14 08:15:33 +01:00
|
|
|
i->BeginDestroy();
|
2017-02-27 22:55:20 +01:00
|
|
|
for (auto *i : outputs)
|
2016-12-14 08:15:33 +01:00
|
|
|
i->FinishDestroy();
|
2014-01-27 08:20:25 +01:00
|
|
|
}
|
|
|
|
|
2017-08-07 18:47:39 +02:00
|
|
|
static FilteredAudioOutput *
|
2016-11-25 13:54:55 +01:00
|
|
|
LoadOutput(EventLoop &event_loop,
|
|
|
|
const ReplayGainConfig &replay_gain_config,
|
|
|
|
MixerListener &mixer_listener,
|
2017-05-23 00:31:13 +02:00
|
|
|
const ConfigBlock &block)
|
2016-10-28 21:11:52 +02:00
|
|
|
try {
|
2016-11-25 13:54:55 +01:00
|
|
|
return audio_output_new(event_loop, replay_gain_config, block,
|
2017-05-23 00:31:13 +02:00
|
|
|
mixer_listener);
|
2017-12-19 10:56:23 +01:00
|
|
|
} catch (...) {
|
2016-10-28 21:11:52 +02:00
|
|
|
if (block.line > 0)
|
2016-11-24 14:04:40 +01:00
|
|
|
std::throw_with_nested(FormatRuntimeError("Failed to configure output in line %i",
|
|
|
|
block.line));
|
2016-10-28 21:11:52 +02:00
|
|
|
else
|
2016-11-24 14:04:40 +01:00
|
|
|
throw;
|
2014-01-27 08:20:25 +01:00
|
|
|
}
|
|
|
|
|
2017-05-22 23:35:32 +02:00
|
|
|
static AudioOutputControl *
|
|
|
|
LoadOutputControl(EventLoop &event_loop,
|
|
|
|
const ReplayGainConfig &replay_gain_config,
|
|
|
|
MixerListener &mixer_listener,
|
|
|
|
AudioOutputClient &client, const ConfigBlock &block)
|
|
|
|
{
|
|
|
|
auto *output = LoadOutput(event_loop, replay_gain_config,
|
|
|
|
mixer_listener,
|
2017-05-23 00:31:13 +02:00
|
|
|
block);
|
|
|
|
auto *control = new AudioOutputControl(output, client);
|
2017-05-22 23:36:45 +02:00
|
|
|
|
|
|
|
try {
|
|
|
|
control->Configure(block);
|
|
|
|
} catch (...) {
|
|
|
|
control->BeginDestroy();
|
|
|
|
control->FinishDestroy();
|
|
|
|
delete control;
|
|
|
|
throw;
|
|
|
|
}
|
|
|
|
|
|
|
|
return control;
|
2017-05-22 23:35:32 +02:00
|
|
|
}
|
|
|
|
|
2014-01-27 08:20:25 +01:00
|
|
|
void
|
2016-11-25 13:54:55 +01:00
|
|
|
MultipleOutputs::Configure(EventLoop &event_loop,
|
|
|
|
const ReplayGainConfig &replay_gain_config,
|
2016-12-14 12:14:57 +01:00
|
|
|
AudioOutputClient &client)
|
2014-01-27 08:20:25 +01:00
|
|
|
{
|
2015-01-21 22:13:44 +01:00
|
|
|
for (const auto *param = config_get_block(ConfigBlockOption::AUDIO_OUTPUT);
|
2014-02-19 23:57:55 +01:00
|
|
|
param != nullptr; param = param->next) {
|
2017-05-22 23:35:32 +02:00
|
|
|
auto *output = LoadOutputControl(event_loop,
|
|
|
|
replay_gain_config,
|
|
|
|
mixer_listener,
|
|
|
|
client, *param);
|
2016-12-29 23:23:28 +01:00
|
|
|
if (FindByName(output->GetName()) != nullptr)
|
2016-11-24 14:04:40 +01:00
|
|
|
throw FormatRuntimeError("output devices with identical "
|
2016-12-29 23:23:28 +01:00
|
|
|
"names: %s", output->GetName());
|
2014-01-27 08:20:25 +01:00
|
|
|
|
2017-05-22 23:35:32 +02:00
|
|
|
outputs.push_back(output);
|
2014-01-27 08:20:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (outputs.empty()) {
|
|
|
|
/* auto-detect device */
|
2015-01-21 22:13:44 +01:00
|
|
|
const ConfigBlock empty;
|
2017-05-22 23:35:32 +02:00
|
|
|
auto *output = LoadOutputControl(event_loop,
|
|
|
|
replay_gain_config,
|
|
|
|
mixer_listener,
|
|
|
|
client, empty);
|
|
|
|
outputs.push_back(output);
|
2014-01-27 08:20:25 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-02-17 23:53:44 +01:00
|
|
|
void
|
|
|
|
MultipleOutputs::AddNullOutput(EventLoop &event_loop,
|
|
|
|
const ReplayGainConfig &replay_gain_config,
|
|
|
|
AudioOutputClient &client)
|
|
|
|
{
|
|
|
|
ConfigBlock block;
|
|
|
|
block.AddBlockParam("type", "null");
|
|
|
|
|
2017-05-23 00:31:31 +02:00
|
|
|
auto *output = LoadOutputControl(event_loop, replay_gain_config,
|
|
|
|
mixer_listener,
|
|
|
|
client, block);
|
|
|
|
outputs.push_back(output);
|
2017-02-17 23:53:44 +01:00
|
|
|
}
|
|
|
|
|
2017-02-27 22:55:20 +01:00
|
|
|
AudioOutputControl *
|
2017-05-15 23:01:49 +02:00
|
|
|
MultipleOutputs::FindByName(const char *name) noexcept
|
2014-01-27 08:20:25 +01:00
|
|
|
{
|
2017-02-27 22:55:20 +01:00
|
|
|
for (auto *i : outputs)
|
2016-12-29 23:23:28 +01:00
|
|
|
if (strcmp(i->GetName(), name) == 0)
|
2014-01-27 08:20:25 +01:00
|
|
|
return i;
|
|
|
|
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
MultipleOutputs::EnableDisable()
|
|
|
|
{
|
2016-12-14 08:41:22 +01:00
|
|
|
/* parallel execution */
|
|
|
|
|
2017-02-27 22:55:20 +01:00
|
|
|
for (auto *ao : outputs) {
|
2017-01-03 07:11:57 +01:00
|
|
|
const std::lock_guard<Mutex> lock(ao->mutex);
|
2016-12-14 08:41:22 +01:00
|
|
|
ao->EnableDisableAsync();
|
|
|
|
}
|
|
|
|
|
2017-02-27 22:55:20 +01:00
|
|
|
for (auto *ao : outputs) {
|
2017-01-03 07:11:57 +01:00
|
|
|
const std::lock_guard<Mutex> lock(ao->mutex);
|
2016-12-14 08:41:22 +01:00
|
|
|
ao->WaitForCommand();
|
2014-01-27 08:20:25 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2017-05-08 14:44:49 +02:00
|
|
|
MultipleOutputs::AllFinished() const noexcept
|
2014-01-27 08:20:25 +01:00
|
|
|
{
|
2017-02-27 22:55:20 +01:00
|
|
|
for (auto *ao : outputs) {
|
2017-01-03 07:11:57 +01:00
|
|
|
const std::lock_guard<Mutex> protect(ao->mutex);
|
2017-04-18 23:15:46 +02:00
|
|
|
if (ao->IsBusy())
|
2014-01-27 08:20:25 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2017-05-08 14:44:49 +02:00
|
|
|
MultipleOutputs::WaitAll() noexcept
|
2014-01-27 08:20:25 +01:00
|
|
|
{
|
|
|
|
while (!AllFinished())
|
|
|
|
audio_output_client_notify.Wait();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2017-12-29 16:29:49 +01:00
|
|
|
MultipleOutputs::AllowPlay() noexcept
|
2014-01-27 08:20:25 +01:00
|
|
|
{
|
2017-02-27 22:55:20 +01:00
|
|
|
for (auto *ao : outputs)
|
2014-01-28 11:39:12 +01:00
|
|
|
ao->LockAllowPlay();
|
2014-01-27 08:20:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2017-12-29 16:29:49 +01:00
|
|
|
MultipleOutputs::Update(bool force) noexcept
|
2014-01-27 08:20:25 +01:00
|
|
|
{
|
|
|
|
bool ret = false;
|
|
|
|
|
|
|
|
if (!input_audio_format.IsDefined())
|
|
|
|
return false;
|
|
|
|
|
2017-02-27 22:55:20 +01:00
|
|
|
for (auto *ao : outputs)
|
2016-12-29 23:20:26 +01:00
|
|
|
ret = ao->LockUpdate(input_audio_format, *pipe, force)
|
2014-01-27 08:20:25 +01:00
|
|
|
|| ret;
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2017-12-29 16:29:49 +01:00
|
|
|
MultipleOutputs::SetReplayGainMode(ReplayGainMode mode) noexcept
|
2014-01-27 08:20:25 +01:00
|
|
|
{
|
2017-02-27 22:55:20 +01:00
|
|
|
for (auto *ao : outputs)
|
2014-01-28 11:39:12 +01:00
|
|
|
ao->SetReplayGainMode(mode);
|
2014-01-27 08:20:25 +01:00
|
|
|
}
|
|
|
|
|
2016-11-09 12:31:23 +01:00
|
|
|
void
|
|
|
|
MultipleOutputs::Play(MusicChunk *chunk)
|
2014-01-27 08:20:25 +01:00
|
|
|
{
|
|
|
|
assert(buffer != nullptr);
|
|
|
|
assert(pipe != nullptr);
|
|
|
|
assert(chunk != nullptr);
|
|
|
|
assert(chunk->CheckFormat(input_audio_format));
|
|
|
|
|
2016-12-29 23:20:26 +01:00
|
|
|
if (!Update(false))
|
2014-01-27 08:20:25 +01:00
|
|
|
/* TODO: obtain real error */
|
2016-11-09 12:31:23 +01:00
|
|
|
throw std::runtime_error("Failed to open audio output");
|
2014-01-27 08:20:25 +01:00
|
|
|
|
|
|
|
pipe->Push(chunk);
|
|
|
|
|
2017-02-27 22:55:20 +01:00
|
|
|
for (auto *ao : outputs)
|
2014-01-28 11:39:12 +01:00
|
|
|
ao->LockPlay();
|
2014-01-27 08:20:25 +01:00
|
|
|
}
|
|
|
|
|
2016-11-09 12:31:23 +01:00
|
|
|
void
|
2014-01-27 08:20:25 +01:00
|
|
|
MultipleOutputs::Open(const AudioFormat audio_format,
|
2016-11-09 12:31:23 +01:00
|
|
|
MusicBuffer &_buffer)
|
2014-01-27 08:20:25 +01:00
|
|
|
{
|
|
|
|
bool ret = false, enabled = false;
|
|
|
|
|
|
|
|
assert(buffer == nullptr || buffer == &_buffer);
|
|
|
|
assert((pipe == nullptr) == (buffer == nullptr));
|
|
|
|
|
|
|
|
buffer = &_buffer;
|
|
|
|
|
|
|
|
/* the audio format must be the same as existing chunks in the
|
|
|
|
pipe */
|
|
|
|
assert(pipe == nullptr || pipe->CheckFormat(audio_format));
|
|
|
|
|
|
|
|
if (pipe == nullptr)
|
|
|
|
pipe = new MusicPipe();
|
|
|
|
else
|
|
|
|
/* if the pipe hasn't been cleared, the the audio
|
|
|
|
format must not have changed */
|
|
|
|
assert(pipe->IsEmpty() || audio_format == input_audio_format);
|
|
|
|
|
|
|
|
input_audio_format = audio_format;
|
|
|
|
|
|
|
|
EnableDisable();
|
2016-12-29 23:20:26 +01:00
|
|
|
Update(true);
|
2014-01-27 08:20:25 +01:00
|
|
|
|
2016-12-29 14:26:10 +01:00
|
|
|
std::exception_ptr first_error;
|
|
|
|
|
2017-02-27 22:55:20 +01:00
|
|
|
for (auto *ao : outputs) {
|
2017-01-03 07:11:57 +01:00
|
|
|
const std::lock_guard<Mutex> lock(ao->mutex);
|
2016-12-29 23:24:49 +01:00
|
|
|
|
2016-12-29 23:23:28 +01:00
|
|
|
if (ao->IsEnabled())
|
2014-01-27 08:20:25 +01:00
|
|
|
enabled = true;
|
|
|
|
|
2016-12-29 23:23:28 +01:00
|
|
|
if (ao->IsOpen())
|
2014-01-27 08:20:25 +01:00
|
|
|
ret = true;
|
2016-12-29 23:23:28 +01:00
|
|
|
else if (!first_error)
|
|
|
|
first_error = ao->GetLastError();
|
2014-01-27 08:20:25 +01:00
|
|
|
}
|
|
|
|
|
2016-11-09 12:31:23 +01:00
|
|
|
if (!enabled) {
|
2014-01-27 08:20:25 +01:00
|
|
|
/* close all devices if there was an error */
|
|
|
|
Close();
|
2016-11-09 12:31:23 +01:00
|
|
|
throw std::runtime_error("All audio outputs are disabled");
|
|
|
|
} else if (!ret) {
|
|
|
|
/* close all devices if there was an error */
|
|
|
|
Close();
|
2016-12-29 14:26:10 +01:00
|
|
|
|
|
|
|
if (first_error)
|
|
|
|
/* we have details, so throw that */
|
|
|
|
std::rethrow_exception(first_error);
|
|
|
|
else
|
|
|
|
throw std::runtime_error("Failed to open audio output");
|
2016-11-09 12:31:23 +01:00
|
|
|
}
|
2014-01-27 08:20:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2017-05-08 14:44:49 +02:00
|
|
|
MultipleOutputs::IsChunkConsumed(const MusicChunk *chunk) const noexcept
|
2014-01-27 08:20:25 +01:00
|
|
|
{
|
2017-02-27 22:55:20 +01:00
|
|
|
for (auto *ao : outputs)
|
2016-12-11 21:59:28 +01:00
|
|
|
if (!ao->LockIsChunkConsumed(*chunk))
|
2014-01-27 08:20:25 +01:00
|
|
|
return false;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void
|
2016-12-12 15:24:38 +01:00
|
|
|
MultipleOutputs::ClearTailChunk(const MusicChunk *chunk,
|
2017-12-29 16:29:49 +01:00
|
|
|
bool *locked) noexcept
|
2014-01-27 08:20:25 +01:00
|
|
|
{
|
|
|
|
assert(chunk->next == nullptr);
|
|
|
|
assert(pipe->Contains(chunk));
|
|
|
|
|
|
|
|
for (unsigned i = 0, n = outputs.size(); i != n; ++i) {
|
2017-02-27 22:55:20 +01:00
|
|
|
auto *ao = outputs[i];
|
2014-01-27 08:20:25 +01:00
|
|
|
|
|
|
|
/* this mutex will be unlocked by the caller when it's
|
|
|
|
ready */
|
|
|
|
ao->mutex.lock();
|
2016-12-29 23:23:28 +01:00
|
|
|
locked[i] = ao->IsOpen();
|
2014-01-27 08:20:25 +01:00
|
|
|
|
|
|
|
if (!locked[i]) {
|
|
|
|
ao->mutex.unlock();
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2016-12-22 14:46:59 +01:00
|
|
|
ao->ClearTailChunk(*chunk);
|
2014-01-27 08:20:25 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned
|
2017-12-29 16:23:19 +01:00
|
|
|
MultipleOutputs::CheckPipe() noexcept
|
2014-01-27 08:20:25 +01:00
|
|
|
{
|
2014-08-12 15:56:41 +02:00
|
|
|
const MusicChunk *chunk;
|
2014-01-27 08:20:25 +01:00
|
|
|
bool is_tail;
|
2014-08-12 15:56:41 +02:00
|
|
|
MusicChunk *shifted;
|
2014-01-27 08:20:25 +01:00
|
|
|
bool locked[outputs.size()];
|
|
|
|
|
|
|
|
assert(buffer != nullptr);
|
|
|
|
assert(pipe != nullptr);
|
|
|
|
|
|
|
|
while ((chunk = pipe->Peek()) != nullptr) {
|
|
|
|
assert(!pipe->IsEmpty());
|
|
|
|
|
|
|
|
if (!IsChunkConsumed(chunk))
|
|
|
|
/* at least one output is not finished playing
|
|
|
|
this chunk */
|
|
|
|
return pipe->GetSize();
|
|
|
|
|
2014-08-29 13:15:33 +02:00
|
|
|
if (chunk->length > 0 && !chunk->time.IsNegative())
|
2014-01-27 08:20:25 +01:00
|
|
|
/* only update elapsed_time if the chunk
|
|
|
|
provides a defined value */
|
2014-08-29 13:15:33 +02:00
|
|
|
elapsed_time = chunk->time;
|
2014-01-27 08:20:25 +01:00
|
|
|
|
|
|
|
is_tail = chunk->next == nullptr;
|
|
|
|
if (is_tail)
|
|
|
|
/* this is the tail of the pipe - clear the
|
|
|
|
chunk reference in all outputs */
|
|
|
|
ClearTailChunk(chunk, locked);
|
|
|
|
|
|
|
|
/* remove the chunk from the pipe */
|
|
|
|
shifted = pipe->Shift();
|
|
|
|
assert(shifted == chunk);
|
|
|
|
|
|
|
|
if (is_tail)
|
|
|
|
/* unlock all audio outputs which were locked
|
|
|
|
by clear_tail_chunk() */
|
|
|
|
for (unsigned i = 0, n = outputs.size(); i != n; ++i)
|
|
|
|
if (locked[i])
|
|
|
|
outputs[i]->mutex.unlock();
|
|
|
|
|
|
|
|
/* return the chunk to the buffer */
|
|
|
|
buffer->Return(shifted);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2017-12-29 16:29:49 +01:00
|
|
|
MultipleOutputs::Pause() noexcept
|
2014-01-27 08:20:25 +01:00
|
|
|
{
|
2016-12-29 23:20:26 +01:00
|
|
|
Update(false);
|
2014-01-27 08:20:25 +01:00
|
|
|
|
2017-02-27 22:55:20 +01:00
|
|
|
for (auto *ao : outputs)
|
2014-01-28 11:39:12 +01:00
|
|
|
ao->LockPauseAsync();
|
2014-01-27 08:20:25 +01:00
|
|
|
|
|
|
|
WaitAll();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2017-12-29 16:29:49 +01:00
|
|
|
MultipleOutputs::Drain() noexcept
|
2014-01-27 08:20:25 +01:00
|
|
|
{
|
2017-02-27 22:55:20 +01:00
|
|
|
for (auto *ao : outputs)
|
2014-01-28 11:39:12 +01:00
|
|
|
ao->LockDrainAsync();
|
2014-01-27 08:20:25 +01:00
|
|
|
|
|
|
|
WaitAll();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2017-12-29 16:29:49 +01:00
|
|
|
MultipleOutputs::Cancel() noexcept
|
2014-01-27 08:20:25 +01:00
|
|
|
{
|
|
|
|
/* send the cancel() command to all audio outputs */
|
|
|
|
|
2017-02-27 22:55:20 +01:00
|
|
|
for (auto *ao : outputs)
|
2014-01-28 11:39:12 +01:00
|
|
|
ao->LockCancelAsync();
|
2014-01-27 08:20:25 +01:00
|
|
|
|
|
|
|
WaitAll();
|
|
|
|
|
|
|
|
/* clear the music pipe and return all chunks to the buffer */
|
|
|
|
|
|
|
|
if (pipe != nullptr)
|
|
|
|
pipe->Clear(*buffer);
|
|
|
|
|
|
|
|
/* the audio outputs are now waiting for a signal, to
|
|
|
|
synchronize the cleared music pipe */
|
|
|
|
|
|
|
|
AllowPlay();
|
|
|
|
|
|
|
|
/* invalidate elapsed_time */
|
|
|
|
|
2014-08-29 13:13:08 +02:00
|
|
|
elapsed_time = SignedSongTime::Negative();
|
2014-01-27 08:20:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2017-12-29 16:29:49 +01:00
|
|
|
MultipleOutputs::Close() noexcept
|
2014-01-27 08:20:25 +01:00
|
|
|
{
|
2017-02-27 22:55:20 +01:00
|
|
|
for (auto *ao : outputs)
|
2014-01-28 11:39:12 +01:00
|
|
|
ao->LockCloseWait();
|
2014-01-27 08:20:25 +01:00
|
|
|
|
|
|
|
if (pipe != nullptr) {
|
|
|
|
assert(buffer != nullptr);
|
|
|
|
|
|
|
|
pipe->Clear(*buffer);
|
|
|
|
delete pipe;
|
|
|
|
pipe = nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
buffer = nullptr;
|
|
|
|
|
|
|
|
input_audio_format.Clear();
|
|
|
|
|
2014-08-29 13:13:08 +02:00
|
|
|
elapsed_time = SignedSongTime::Negative();
|
2014-01-27 08:20:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2017-12-29 16:29:49 +01:00
|
|
|
MultipleOutputs::Release() noexcept
|
2014-01-27 08:20:25 +01:00
|
|
|
{
|
2017-02-27 22:55:20 +01:00
|
|
|
for (auto *ao : outputs)
|
2014-01-28 11:39:12 +01:00
|
|
|
ao->LockRelease();
|
2014-01-27 08:20:25 +01:00
|
|
|
|
|
|
|
if (pipe != nullptr) {
|
|
|
|
assert(buffer != nullptr);
|
|
|
|
|
|
|
|
pipe->Clear(*buffer);
|
|
|
|
delete pipe;
|
|
|
|
pipe = nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
buffer = nullptr;
|
|
|
|
|
|
|
|
input_audio_format.Clear();
|
|
|
|
|
2014-08-29 13:13:08 +02:00
|
|
|
elapsed_time = SignedSongTime::Negative();
|
2014-01-27 08:20:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2017-12-29 16:29:49 +01:00
|
|
|
MultipleOutputs::SongBorder() noexcept
|
2014-01-27 08:20:25 +01:00
|
|
|
{
|
|
|
|
/* clear the elapsed_time pointer at the beginning of a new
|
|
|
|
song */
|
2014-08-29 13:13:08 +02:00
|
|
|
elapsed_time = SignedSongTime::zero();
|
2014-01-27 08:20:25 +01:00
|
|
|
}
|