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