output/Interface: convert to class, make attributes private
This commit is contained in:
parent
7381236de6
commit
9c9a9ccd5c
@ -32,15 +32,15 @@
|
||||
bool
|
||||
FilteredAudioOutput::SupportsEnableDisable() const noexcept
|
||||
{
|
||||
assert((output->plugin.enable == nullptr) == (output->plugin.disable == nullptr));
|
||||
assert((output->GetPlugin().enable == nullptr) == (output->GetPlugin().disable == nullptr));
|
||||
|
||||
return output->plugin.enable != nullptr;
|
||||
return output->GetPlugin().enable != nullptr;
|
||||
}
|
||||
|
||||
bool
|
||||
FilteredAudioOutput::SupportsPause() const noexcept
|
||||
{
|
||||
return output->plugin.pause != nullptr;
|
||||
return output->GetPlugin().pause != nullptr;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -33,7 +33,7 @@ class Mixer;
|
||||
class MixerListener;
|
||||
struct MusicChunk;
|
||||
struct ConfigBlock;
|
||||
struct AudioOutput;
|
||||
class AudioOutput;
|
||||
struct ReplayGainConfig;
|
||||
struct Tag;
|
||||
|
||||
|
@ -55,7 +55,7 @@ FilteredAudioOutput::FilteredAudioOutput(AudioOutput &_output,
|
||||
:output(&_output)
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
const auto &plugin = output->plugin;
|
||||
const auto &plugin = output->GetPlugin();
|
||||
assert(plugin.finish != nullptr);
|
||||
assert(plugin.open != nullptr);
|
||||
assert(plugin.close != nullptr);
|
||||
@ -172,7 +172,7 @@ FilteredAudioOutput::Configure(const ConfigBlock &block)
|
||||
{
|
||||
char buffer[64];
|
||||
snprintf(buffer, sizeof(buffer), "\"%s\" (%s)",
|
||||
name, output->plugin.name);
|
||||
name, output->GetPlugin().name);
|
||||
log_name = buffer;
|
||||
}
|
||||
|
||||
@ -207,7 +207,7 @@ FilteredAudioOutput::Setup(EventLoop &event_loop,
|
||||
MixerListener &mixer_listener,
|
||||
const ConfigBlock &block)
|
||||
{
|
||||
if (output->need_fully_defined_audio_format &&
|
||||
if (output->GetNeedFullyDefinedAudioFormat() &&
|
||||
!config_audio_format.IsFullyDefined())
|
||||
throw std::runtime_error("Need full audio format specification");
|
||||
|
||||
@ -233,7 +233,7 @@ FilteredAudioOutput::Setup(EventLoop &event_loop,
|
||||
|
||||
try {
|
||||
mixer = audio_output_load_mixer(event_loop, *this, block,
|
||||
output->plugin.mixer_plugin,
|
||||
output->GetPlugin().mixer_plugin,
|
||||
*prepared_filter,
|
||||
mixer_listener);
|
||||
} catch (const std::runtime_error &e) {
|
||||
|
@ -22,7 +22,7 @@
|
||||
|
||||
struct AudioOutputPlugin;
|
||||
|
||||
struct AudioOutput {
|
||||
class AudioOutput {
|
||||
/**
|
||||
* The plugin which implements this output device.
|
||||
*/
|
||||
@ -30,9 +30,18 @@ struct AudioOutput {
|
||||
|
||||
bool need_fully_defined_audio_format = false;
|
||||
|
||||
public:
|
||||
AudioOutput(const AudioOutputPlugin &_plugin)
|
||||
:plugin(_plugin) {}
|
||||
|
||||
const AudioOutputPlugin &GetPlugin() const {
|
||||
return plugin;
|
||||
}
|
||||
|
||||
bool GetNeedFullyDefinedAudioFormat() const {
|
||||
return need_fully_defined_audio_format;
|
||||
}
|
||||
|
||||
/**
|
||||
* Plugins shall call this method if they require an
|
||||
* "audio_format" setting which evaluates
|
||||
|
@ -36,72 +36,72 @@ ao_plugin_init(EventLoop &event_loop,
|
||||
void
|
||||
ao_plugin_finish(AudioOutput *ao) noexcept
|
||||
{
|
||||
ao->plugin.finish(ao);
|
||||
ao->GetPlugin().finish(ao);
|
||||
}
|
||||
|
||||
void
|
||||
ao_plugin_enable(AudioOutput &ao)
|
||||
{
|
||||
if (ao.plugin.enable != nullptr)
|
||||
ao.plugin.enable(&ao);
|
||||
if (ao.GetPlugin().enable != nullptr)
|
||||
ao.GetPlugin().enable(&ao);
|
||||
}
|
||||
|
||||
void
|
||||
ao_plugin_disable(AudioOutput &ao) noexcept
|
||||
{
|
||||
if (ao.plugin.disable != nullptr)
|
||||
ao.plugin.disable(&ao);
|
||||
if (ao.GetPlugin().disable != nullptr)
|
||||
ao.GetPlugin().disable(&ao);
|
||||
}
|
||||
|
||||
void
|
||||
ao_plugin_open(AudioOutput &ao, AudioFormat &audio_format)
|
||||
{
|
||||
ao.plugin.open(&ao, audio_format);
|
||||
ao.GetPlugin().open(&ao, audio_format);
|
||||
}
|
||||
|
||||
void
|
||||
ao_plugin_close(AudioOutput &ao) noexcept
|
||||
{
|
||||
ao.plugin.close(&ao);
|
||||
ao.GetPlugin().close(&ao);
|
||||
}
|
||||
|
||||
std::chrono::steady_clock::duration
|
||||
ao_plugin_delay(AudioOutput &ao) noexcept
|
||||
{
|
||||
return ao.plugin.delay != nullptr
|
||||
? ao.plugin.delay(&ao)
|
||||
return ao.GetPlugin().delay != nullptr
|
||||
? ao.GetPlugin().delay(&ao)
|
||||
: std::chrono::steady_clock::duration::zero();
|
||||
}
|
||||
|
||||
void
|
||||
ao_plugin_send_tag(AudioOutput &ao, const Tag &tag)
|
||||
{
|
||||
if (ao.plugin.send_tag != nullptr)
|
||||
ao.plugin.send_tag(&ao, tag);
|
||||
if (ao.GetPlugin().send_tag != nullptr)
|
||||
ao.GetPlugin().send_tag(&ao, tag);
|
||||
}
|
||||
|
||||
size_t
|
||||
ao_plugin_play(AudioOutput &ao, const void *chunk, size_t size)
|
||||
{
|
||||
return ao.plugin.play(&ao, chunk, size);
|
||||
return ao.GetPlugin().play(&ao, chunk, size);
|
||||
}
|
||||
|
||||
void
|
||||
ao_plugin_drain(AudioOutput &ao)
|
||||
{
|
||||
if (ao.plugin.drain != nullptr)
|
||||
ao.plugin.drain(&ao);
|
||||
if (ao.GetPlugin().drain != nullptr)
|
||||
ao.GetPlugin().drain(&ao);
|
||||
}
|
||||
|
||||
void
|
||||
ao_plugin_cancel(AudioOutput &ao) noexcept
|
||||
{
|
||||
if (ao.plugin.cancel != nullptr)
|
||||
ao.plugin.cancel(&ao);
|
||||
if (ao.GetPlugin().cancel != nullptr)
|
||||
ao.GetPlugin().cancel(&ao);
|
||||
}
|
||||
|
||||
bool
|
||||
ao_plugin_pause(AudioOutput &ao)
|
||||
{
|
||||
return ao.plugin.pause != nullptr && ao.plugin.pause(&ao);
|
||||
return ao.GetPlugin().pause != nullptr && ao.GetPlugin().pause(&ao);
|
||||
}
|
||||
|
@ -29,7 +29,7 @@
|
||||
struct ConfigBlock;
|
||||
struct AudioFormat;
|
||||
struct Tag;
|
||||
struct AudioOutput;
|
||||
class AudioOutput;
|
||||
struct MixerPlugin;
|
||||
class EventLoop;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user