From d0157af13e2ce32136504a6a62945fa7213d6861 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 7 Aug 2017 18:47:39 +0200 Subject: [PATCH] filter/Internal: rename struct AudioOutput to FilteredAudioOutput Prepare to add an abstract class AudioOutput, to be implemented by plugins, to get rid of the C-style vtable. --- src/mixer/MixerControl.cxx | 2 +- src/mixer/MixerControl.hxx | 5 +- src/mixer/MixerPlugin.hxx | 6 +-- src/mixer/plugins/AlsaMixerPlugin.cxx | 2 +- src/mixer/plugins/HaikuMixerPlugin.cxx | 2 +- src/mixer/plugins/NullMixerPlugin.cxx | 2 +- src/mixer/plugins/OssMixerPlugin.cxx | 3 +- src/mixer/plugins/PulseMixerPlugin.cxx | 2 +- src/mixer/plugins/RoarMixerPlugin.cxx | 2 +- src/mixer/plugins/SoftwareMixerPlugin.cxx | 2 +- src/mixer/plugins/WinmmMixerPlugin.cxx | 2 +- src/output/Control.cxx | 2 +- src/output/Control.hxx | 13 +++-- src/output/Finish.cxx | 6 +-- src/output/Init.cxx | 20 ++++---- src/output/Internal.cxx | 20 ++++---- src/output/Internal.hxx | 10 ++-- src/output/MultipleOutputs.cxx | 2 +- src/output/MultipleOutputs.hxx | 1 - src/output/OutputPlugin.cxx | 24 +++++----- src/output/OutputPlugin.hxx | 50 ++++++++++---------- src/output/Wrapper.hxx | 28 +++++------ src/output/plugins/AlsaOutputPlugin.cxx | 2 +- src/output/plugins/AoOutputPlugin.cxx | 2 +- src/output/plugins/FifoOutputPlugin.cxx | 2 +- src/output/plugins/HaikuOutputPlugin.cxx | 2 +- src/output/plugins/JackOutputPlugin.cxx | 4 +- src/output/plugins/NullOutputPlugin.cxx | 2 +- src/output/plugins/OSXOutputPlugin.cxx | 18 +++---- src/output/plugins/OpenALOutputPlugin.cxx | 2 +- src/output/plugins/OssOutputPlugin.cxx | 2 +- src/output/plugins/PipeOutputPlugin.cxx | 2 +- src/output/plugins/PulseOutputPlugin.cxx | 2 +- src/output/plugins/RecorderOutputPlugin.cxx | 2 +- src/output/plugins/RoarOutputPlugin.cxx | 4 +- src/output/plugins/ShoutOutputPlugin.cxx | 2 +- src/output/plugins/SndioOutputPlugin.cxx | 2 +- src/output/plugins/SolarisOutputPlugin.cxx | 2 +- src/output/plugins/WinmmOutputPlugin.cxx | 2 +- src/output/plugins/httpd/HttpdInternal.hxx | 4 +- src/output/plugins/sles/SlesOutputPlugin.cxx | 4 +- test/read_mixer.cxx | 2 +- test/run_output.cxx | 6 +-- 43 files changed, 138 insertions(+), 138 deletions(-) diff --git a/src/mixer/MixerControl.cxx b/src/mixer/MixerControl.cxx index 3c6f86236..117fdfbcd 100644 --- a/src/mixer/MixerControl.cxx +++ b/src/mixer/MixerControl.cxx @@ -25,7 +25,7 @@ Mixer * mixer_new(EventLoop &event_loop, - const MixerPlugin &plugin, AudioOutput &ao, + const MixerPlugin &plugin, FilteredAudioOutput &ao, MixerListener &listener, const ConfigBlock &block) { diff --git a/src/mixer/MixerControl.hxx b/src/mixer/MixerControl.hxx index e71592edb..bc4e54801 100644 --- a/src/mixer/MixerControl.hxx +++ b/src/mixer/MixerControl.hxx @@ -27,7 +27,7 @@ class Mixer; class EventLoop; -struct AudioOutput; +struct FilteredAudioOutput; struct MixerPlugin; class MixerListener; struct ConfigBlock; @@ -36,7 +36,8 @@ struct ConfigBlock; * Throws std::runtime_error on error. */ Mixer * -mixer_new(EventLoop &event_loop, const MixerPlugin &plugin, AudioOutput &ao, +mixer_new(EventLoop &event_loop, const MixerPlugin &plugin, + FilteredAudioOutput &ao, MixerListener &listener, const ConfigBlock &block); diff --git a/src/mixer/MixerPlugin.hxx b/src/mixer/MixerPlugin.hxx index a5693ddd2..d9cded5f5 100644 --- a/src/mixer/MixerPlugin.hxx +++ b/src/mixer/MixerPlugin.hxx @@ -28,7 +28,7 @@ #define MPD_MIXER_PLUGIN_HXX struct ConfigBlock; -struct AudioOutput; +struct FilteredAudioOutput; class Mixer; class MixerListener; class EventLoop; @@ -39,11 +39,11 @@ struct MixerPlugin { * * Throws std::runtime_error on error. * - * @param ao the associated AudioOutput + * @param ao the associated #AudioOutput * @param param the configuration section * @return a mixer object */ - Mixer *(*init)(EventLoop &event_loop, AudioOutput &ao, + Mixer *(*init)(EventLoop &event_loop, FilteredAudioOutput &ao, MixerListener &listener, const ConfigBlock &block); diff --git a/src/mixer/plugins/AlsaMixerPlugin.cxx b/src/mixer/plugins/AlsaMixerPlugin.cxx index 49ec15c3b..76ad79d92 100644 --- a/src/mixer/plugins/AlsaMixerPlugin.cxx +++ b/src/mixer/plugins/AlsaMixerPlugin.cxx @@ -173,7 +173,7 @@ AlsaMixer::Configure(const ConfigBlock &block) } static Mixer * -alsa_mixer_init(EventLoop &event_loop, gcc_unused AudioOutput &ao, +alsa_mixer_init(EventLoop &event_loop, gcc_unused FilteredAudioOutput &ao, MixerListener &listener, const ConfigBlock &block) { diff --git a/src/mixer/plugins/HaikuMixerPlugin.cxx b/src/mixer/plugins/HaikuMixerPlugin.cxx index f0b50a91c..23f096430 100644 --- a/src/mixer/plugins/HaikuMixerPlugin.cxx +++ b/src/mixer/plugins/HaikuMixerPlugin.cxx @@ -48,7 +48,7 @@ public: }; static Mixer * -haiku_mixer_init(gcc_unused EventLoop &event_loop, AudioOutput &ao, +haiku_mixer_init(gcc_unused EventLoop &event_loop, FilteredAudioOutput &ao, MixerListener &listener, gcc_unused const ConfigBlock &block) { diff --git a/src/mixer/plugins/NullMixerPlugin.cxx b/src/mixer/plugins/NullMixerPlugin.cxx index 66b6409b1..bacfe86c2 100644 --- a/src/mixer/plugins/NullMixerPlugin.cxx +++ b/src/mixer/plugins/NullMixerPlugin.cxx @@ -51,7 +51,7 @@ public: static Mixer * null_mixer_init(gcc_unused EventLoop &event_loop, - gcc_unused AudioOutput &ao, + gcc_unused FilteredAudioOutput &ao, MixerListener &listener, gcc_unused const ConfigBlock &block) { diff --git a/src/mixer/plugins/OssMixerPlugin.cxx b/src/mixer/plugins/OssMixerPlugin.cxx index 72cb72a47..23135c477 100644 --- a/src/mixer/plugins/OssMixerPlugin.cxx +++ b/src/mixer/plugins/OssMixerPlugin.cxx @@ -97,7 +97,8 @@ OssMixer::Configure(const ConfigBlock &block) } static Mixer * -oss_mixer_init(gcc_unused EventLoop &event_loop, gcc_unused AudioOutput &ao, +oss_mixer_init(gcc_unused EventLoop &event_loop, + gcc_unused FilteredAudioOutput &ao, MixerListener &listener, const ConfigBlock &block) { diff --git a/src/mixer/plugins/PulseMixerPlugin.cxx b/src/mixer/plugins/PulseMixerPlugin.cxx index 5919e0ee6..670c4053e 100644 --- a/src/mixer/plugins/PulseMixerPlugin.cxx +++ b/src/mixer/plugins/PulseMixerPlugin.cxx @@ -161,7 +161,7 @@ pulse_mixer_on_change(PulseMixer &pm, } static Mixer * -pulse_mixer_init(gcc_unused EventLoop &event_loop, AudioOutput &ao, +pulse_mixer_init(gcc_unused EventLoop &event_loop, FilteredAudioOutput &ao, MixerListener &listener, gcc_unused const ConfigBlock &block) { diff --git a/src/mixer/plugins/RoarMixerPlugin.cxx b/src/mixer/plugins/RoarMixerPlugin.cxx index d3df5f910..e94c6ec78 100644 --- a/src/mixer/plugins/RoarMixerPlugin.cxx +++ b/src/mixer/plugins/RoarMixerPlugin.cxx @@ -45,7 +45,7 @@ public: }; static Mixer * -roar_mixer_init(gcc_unused EventLoop &event_loop, AudioOutput &ao, +roar_mixer_init(gcc_unused EventLoop &event_loop, FilteredAudioOutput &ao, MixerListener &listener, gcc_unused const ConfigBlock &block) { diff --git a/src/mixer/plugins/SoftwareMixerPlugin.cxx b/src/mixer/plugins/SoftwareMixerPlugin.cxx index 0a1684b47..df54a1ae9 100644 --- a/src/mixer/plugins/SoftwareMixerPlugin.cxx +++ b/src/mixer/plugins/SoftwareMixerPlugin.cxx @@ -58,7 +58,7 @@ public: static Mixer * software_mixer_init(gcc_unused EventLoop &event_loop, - gcc_unused AudioOutput &ao, + gcc_unused FilteredAudioOutput &ao, MixerListener &listener, gcc_unused const ConfigBlock &block) { diff --git a/src/mixer/plugins/WinmmMixerPlugin.cxx b/src/mixer/plugins/WinmmMixerPlugin.cxx index bfbbe9d3d..eb00ddf66 100644 --- a/src/mixer/plugins/WinmmMixerPlugin.cxx +++ b/src/mixer/plugins/WinmmMixerPlugin.cxx @@ -64,7 +64,7 @@ winmm_volume_encode(int volume) } static Mixer * -winmm_mixer_init(gcc_unused EventLoop &event_loop, AudioOutput &ao, +winmm_mixer_init(gcc_unused EventLoop &event_loop, FilteredAudioOutput &ao, MixerListener &listener, gcc_unused const ConfigBlock &block) { diff --git a/src/output/Control.cxx b/src/output/Control.cxx index 73c8db654..c15d22467 100644 --- a/src/output/Control.cxx +++ b/src/output/Control.cxx @@ -38,7 +38,7 @@ static constexpr PeriodClock::Duration REOPEN_AFTER = std::chrono::seconds(10); struct notify audio_output_client_notify; -AudioOutputControl::AudioOutputControl(AudioOutput *_output, +AudioOutputControl::AudioOutputControl(FilteredAudioOutput *_output, AudioOutputClient &_client) :output(_output), client(_client), thread(BIND_THIS_METHOD(Task)) diff --git a/src/output/Control.hxx b/src/output/Control.hxx index 5e6dc956a..46bad6898 100644 --- a/src/output/Control.hxx +++ b/src/output/Control.hxx @@ -38,7 +38,7 @@ #include enum class ReplayGainMode : uint8_t; -struct AudioOutput; +struct FilteredAudioOutput; struct MusicChunk; struct ConfigBlock; class MusicPipe; @@ -50,7 +50,7 @@ class AudioOutputClient; * Controller for an #AudioOutput and its output thread. */ class AudioOutputControl { - AudioOutput *output; + FilteredAudioOutput *output; /** * The PlayerControl object which "owns" this output. This @@ -209,7 +209,8 @@ public: */ mutable Mutex mutex; - AudioOutputControl(AudioOutput *_output, AudioOutputClient &_client); + AudioOutputControl(FilteredAudioOutput *_output, + AudioOutputClient &_client); #ifndef NDEBUG ~AudioOutputControl() { @@ -303,16 +304,14 @@ public: void CommandAsync(Command cmd) noexcept; /** - * Sends a command to the #AudioOutput object and waits for - * completion. + * Sends a command to the object and waits for completion. * * Caller must lock the mutex. */ void CommandWait(Command cmd) noexcept; /** - * Lock the #AudioOutput object and execute the command - * synchronously. + * Lock the object and execute the command synchronously. */ void LockCommandWait(Command cmd) noexcept; diff --git a/src/output/Finish.cxx b/src/output/Finish.cxx index dfa7df7f6..c8d372fa0 100644 --- a/src/output/Finish.cxx +++ b/src/output/Finish.cxx @@ -23,7 +23,7 @@ #include "mixer/MixerControl.hxx" #include "filter/FilterInternal.hxx" -AudioOutput::~AudioOutput() +FilteredAudioOutput::~FilteredAudioOutput() { if (mixer != nullptr) mixer_free(mixer); @@ -34,14 +34,14 @@ AudioOutput::~AudioOutput() } void -AudioOutput::BeginDestroy() noexcept +FilteredAudioOutput::BeginDestroy() noexcept { if (mixer != nullptr) mixer_auto_close(mixer); } void -AudioOutput::FinishDestroy() noexcept +FilteredAudioOutput::FinishDestroy() noexcept { ao_plugin_finish(this); } diff --git a/src/output/Init.cxx b/src/output/Init.cxx index 29ee3d530..159c1d63b 100644 --- a/src/output/Init.cxx +++ b/src/output/Init.cxx @@ -50,8 +50,8 @@ #define AUDIO_OUTPUT_FORMAT "format" #define AUDIO_FILTERS "filters" -AudioOutput::AudioOutput(const AudioOutputPlugin &_plugin, - const ConfigBlock &block) +FilteredAudioOutput::FilteredAudioOutput(const AudioOutputPlugin &_plugin, + const ConfigBlock &block) :plugin(_plugin) { assert(plugin.finish != nullptr); @@ -108,7 +108,7 @@ audio_output_mixer_type(const ConfigBlock &block) noexcept } static Mixer * -audio_output_load_mixer(EventLoop &event_loop, AudioOutput &ao, +audio_output_load_mixer(EventLoop &event_loop, FilteredAudioOutput &ao, const ConfigBlock &block, const MixerPlugin *plugin, PreparedFilter &filter_chain, @@ -148,7 +148,7 @@ audio_output_load_mixer(EventLoop &event_loop, AudioOutput &ao, } void -AudioOutput::Configure(const ConfigBlock &block) +FilteredAudioOutput::Configure(const ConfigBlock &block) { if (!block.IsNull()) { name = block.GetBlockValue(AUDIO_OUTPUT_NAME); @@ -192,10 +192,10 @@ AudioOutput::Configure(const ConfigBlock &block) } inline void -AudioOutput::Setup(EventLoop &event_loop, - const ReplayGainConfig &replay_gain_config, - MixerListener &mixer_listener, - const ConfigBlock &block) +FilteredAudioOutput::Setup(EventLoop &event_loop, + const ReplayGainConfig &replay_gain_config, + MixerListener &mixer_listener, + const ConfigBlock &block) { /* create the replay_gain filter */ @@ -249,7 +249,7 @@ AudioOutput::Setup(EventLoop &event_loop, convert_filter.Set(convert_filter_prepare())); } -AudioOutput * +FilteredAudioOutput * audio_output_new(EventLoop &event_loop, const ReplayGainConfig &replay_gain_config, const ConfigBlock &block, @@ -278,7 +278,7 @@ audio_output_new(EventLoop &event_loop, plugin->name); } - AudioOutput *ao = ao_plugin_init(event_loop, *plugin, block); + auto *ao = ao_plugin_init(event_loop, *plugin, block); assert(ao != nullptr); try { diff --git a/src/output/Internal.cxx b/src/output/Internal.cxx index 1d90b47e9..5af69348e 100644 --- a/src/output/Internal.cxx +++ b/src/output/Internal.cxx @@ -29,7 +29,7 @@ #include "util/StringBuffer.hxx" void -AudioOutput::Enable() +FilteredAudioOutput::Enable() { try { ao_plugin_enable(*this); @@ -40,13 +40,13 @@ AudioOutput::Enable() } void -AudioOutput::Disable() noexcept +FilteredAudioOutput::Disable() noexcept { ao_plugin_disable(*this); } void -AudioOutput::ConfigureConvertFilter() +FilteredAudioOutput::ConfigureConvertFilter() { try { convert_filter_set(convert_filter.Get(), out_audio_format); @@ -57,7 +57,7 @@ AudioOutput::ConfigureConvertFilter() } void -AudioOutput::OpenOutputAndConvert(AudioFormat desired_audio_format) +FilteredAudioOutput::OpenOutputAndConvert(AudioFormat desired_audio_format) { out_audio_format = desired_audio_format; @@ -98,7 +98,7 @@ AudioOutput::OpenOutputAndConvert(AudioFormat desired_audio_format) } void -AudioOutput::CloseOutput(bool drain) noexcept +FilteredAudioOutput::CloseOutput(bool drain) noexcept { if (drain) ao_plugin_drain(*this); @@ -109,21 +109,21 @@ AudioOutput::CloseOutput(bool drain) noexcept } void -AudioOutput::OpenSoftwareMixer() noexcept +FilteredAudioOutput::OpenSoftwareMixer() noexcept { if (mixer != nullptr && mixer->IsPlugin(software_mixer_plugin)) software_mixer_set_filter(*mixer, volume_filter.Get()); } void -AudioOutput::CloseSoftwareMixer() noexcept +FilteredAudioOutput::CloseSoftwareMixer() noexcept { if (mixer != nullptr && mixer->IsPlugin(software_mixer_plugin)) software_mixer_set_filter(*mixer, nullptr); } void -AudioOutput::Close(bool drain) noexcept +FilteredAudioOutput::Close(bool drain) noexcept { CloseOutput(drain); CloseSoftwareMixer(); @@ -133,13 +133,13 @@ AudioOutput::Close(bool drain) noexcept } void -AudioOutput::BeginPause() noexcept +FilteredAudioOutput::BeginPause() noexcept { ao_plugin_cancel(*this); } bool -AudioOutput::IteratePause() noexcept +FilteredAudioOutput::IteratePause() noexcept { try { return ao_plugin_pause(*this); diff --git a/src/output/Internal.hxx b/src/output/Internal.hxx index 4326fe1a3..3e374d733 100644 --- a/src/output/Internal.hxx +++ b/src/output/Internal.hxx @@ -33,7 +33,7 @@ struct ConfigBlock; struct AudioOutputPlugin; struct ReplayGainConfig; -struct AudioOutput { +struct FilteredAudioOutput { /** * The device's configured display name. */ @@ -108,10 +108,10 @@ struct AudioOutput { /** * Throws #std::runtime_error on error. */ - AudioOutput(const AudioOutputPlugin &_plugin, - const ConfigBlock &block); + FilteredAudioOutput(const AudioOutputPlugin &_plugin, + const ConfigBlock &block); - ~AudioOutput(); + ~FilteredAudioOutput(); private: void Configure(const ConfigBlock &block); @@ -188,7 +188,7 @@ extern struct notify audio_output_client_notify; /** * Throws #std::runtime_error on error. */ -AudioOutput * +FilteredAudioOutput * audio_output_new(EventLoop &event_loop, const ReplayGainConfig &replay_gain_config, const ConfigBlock &block, diff --git a/src/output/MultipleOutputs.cxx b/src/output/MultipleOutputs.cxx index 0be03f14c..13dd62809 100644 --- a/src/output/MultipleOutputs.cxx +++ b/src/output/MultipleOutputs.cxx @@ -49,7 +49,7 @@ MultipleOutputs::~MultipleOutputs() i->FinishDestroy(); } -static AudioOutput * +static FilteredAudioOutput * LoadOutput(EventLoop &event_loop, const ReplayGainConfig &replay_gain_config, MixerListener &mixer_listener, diff --git a/src/output/MultipleOutputs.hxx b/src/output/MultipleOutputs.hxx index 3febfeecb..65748a9be 100644 --- a/src/output/MultipleOutputs.hxx +++ b/src/output/MultipleOutputs.hxx @@ -42,7 +42,6 @@ class EventLoop; class MixerListener; class AudioOutputClient; struct MusicChunk; -struct AudioOutput; struct ReplayGainConfig; class MultipleOutputs { diff --git a/src/output/OutputPlugin.cxx b/src/output/OutputPlugin.cxx index 51f02154b..882553513 100644 --- a/src/output/OutputPlugin.cxx +++ b/src/output/OutputPlugin.cxx @@ -21,7 +21,7 @@ #include "OutputPlugin.hxx" #include "Internal.hxx" -AudioOutput * +FilteredAudioOutput * ao_plugin_init(EventLoop &event_loop, const AudioOutputPlugin &plugin, const ConfigBlock &block) @@ -32,39 +32,39 @@ ao_plugin_init(EventLoop &event_loop, } void -ao_plugin_finish(AudioOutput *ao) noexcept +ao_plugin_finish(FilteredAudioOutput *ao) noexcept { ao->plugin.finish(ao); } void -ao_plugin_enable(AudioOutput &ao) +ao_plugin_enable(FilteredAudioOutput &ao) { if (ao.plugin.enable != nullptr) ao.plugin.enable(&ao); } void -ao_plugin_disable(AudioOutput &ao) noexcept +ao_plugin_disable(FilteredAudioOutput &ao) noexcept { if (ao.plugin.disable != nullptr) ao.plugin.disable(&ao); } void -ao_plugin_open(AudioOutput &ao, AudioFormat &audio_format) +ao_plugin_open(FilteredAudioOutput &ao, AudioFormat &audio_format) { ao.plugin.open(&ao, audio_format); } void -ao_plugin_close(AudioOutput &ao) noexcept +ao_plugin_close(FilteredAudioOutput &ao) noexcept { ao.plugin.close(&ao); } std::chrono::steady_clock::duration -ao_plugin_delay(AudioOutput &ao) noexcept +ao_plugin_delay(FilteredAudioOutput &ao) noexcept { return ao.plugin.delay != nullptr ? ao.plugin.delay(&ao) @@ -72,34 +72,34 @@ ao_plugin_delay(AudioOutput &ao) noexcept } void -ao_plugin_send_tag(AudioOutput &ao, const Tag &tag) +ao_plugin_send_tag(FilteredAudioOutput &ao, const Tag &tag) { if (ao.plugin.send_tag != nullptr) ao.plugin.send_tag(&ao, tag); } size_t -ao_plugin_play(AudioOutput &ao, const void *chunk, size_t size) +ao_plugin_play(FilteredAudioOutput &ao, const void *chunk, size_t size) { return ao.plugin.play(&ao, chunk, size); } void -ao_plugin_drain(AudioOutput &ao) +ao_plugin_drain(FilteredAudioOutput &ao) { if (ao.plugin.drain != nullptr) ao.plugin.drain(&ao); } void -ao_plugin_cancel(AudioOutput &ao) noexcept +ao_plugin_cancel(FilteredAudioOutput &ao) noexcept { if (ao.plugin.cancel != nullptr) ao.plugin.cancel(&ao); } bool -ao_plugin_pause(AudioOutput &ao) +ao_plugin_pause(FilteredAudioOutput &ao) { return ao.plugin.pause != nullptr && ao.plugin.pause(&ao); } diff --git a/src/output/OutputPlugin.hxx b/src/output/OutputPlugin.hxx index 5ce52e15c..bea770b94 100644 --- a/src/output/OutputPlugin.hxx +++ b/src/output/OutputPlugin.hxx @@ -29,7 +29,7 @@ struct ConfigBlock; struct AudioFormat; struct Tag; -struct AudioOutput; +struct FilteredAudioOutput; struct MixerPlugin; class EventLoop; @@ -57,12 +57,12 @@ struct AudioOutputPlugin { * @param param the configuration section, or nullptr if there is * no configuration */ - AudioOutput *(*init)(EventLoop &event_loop, const ConfigBlock &block); + FilteredAudioOutput *(*init)(EventLoop &event_loop, const ConfigBlock &block); /** * Free resources allocated by this device. */ - void (*finish)(AudioOutput *data); + void (*finish)(FilteredAudioOutput *data); /** * Enable the device. This may allocate resources, preparing @@ -70,13 +70,13 @@ struct AudioOutputPlugin { * * Throws #std::runtime_error on error. */ - void (*enable)(AudioOutput *data); + void (*enable)(FilteredAudioOutput *data); /** * Disables the device. It is closed before this method is * called. */ - void (*disable)(AudioOutput *data); + void (*disable)(FilteredAudioOutput *data); /** * Really open the device. @@ -86,12 +86,12 @@ struct AudioOutputPlugin { * @param audio_format the audio format in which data is going * to be delivered; may be modified by the plugin */ - void (*open)(AudioOutput *data, AudioFormat &audio_format); + void (*open)(FilteredAudioOutput *data, AudioFormat &audio_format); /** * Close the device. */ - void (*close)(AudioOutput *data); + void (*close)(FilteredAudioOutput *data); /** * Returns a positive number if the output thread shall further @@ -102,13 +102,13 @@ struct AudioOutputPlugin { * * @return the duration to wait */ - std::chrono::steady_clock::duration (*delay)(AudioOutput *data) noexcept; + std::chrono::steady_clock::duration (*delay)(FilteredAudioOutput *data) noexcept; /** * Display metadata for the next chunk. Optional method, * because not all devices can display metadata. */ - void (*send_tag)(AudioOutput *data, const Tag &tag); + void (*send_tag)(FilteredAudioOutput *data, const Tag &tag); /** * Play a chunk of audio data. @@ -117,19 +117,19 @@ struct AudioOutputPlugin { * * @return the number of bytes played */ - size_t (*play)(AudioOutput *data, + size_t (*play)(FilteredAudioOutput *data, const void *chunk, size_t size); /** * Wait until the device has finished playing. */ - void (*drain)(AudioOutput *data); + void (*drain)(FilteredAudioOutput *data); /** * Try to cancel data which may still be in the device's * buffers. */ - void (*cancel)(AudioOutput *data); + void (*cancel)(FilteredAudioOutput *data); /** * Pause the device. If supported, it may perform a special @@ -142,7 +142,7 @@ struct AudioOutputPlugin { * @return false on error (output will be closed by caller), * true for continue to pause */ - bool (*pause)(AudioOutput *data); + bool (*pause)(FilteredAudioOutput *data); /** * The mixer plugin associated with this output plugin. This @@ -162,43 +162,43 @@ ao_plugin_test_default_device(const AudioOutputPlugin *plugin) } gcc_malloc -AudioOutput * +FilteredAudioOutput * ao_plugin_init(EventLoop &event_loop, const AudioOutputPlugin &plugin, const ConfigBlock &block); void -ao_plugin_finish(AudioOutput *ao) noexcept; +ao_plugin_finish(FilteredAudioOutput *ao) noexcept; void -ao_plugin_enable(AudioOutput &ao); +ao_plugin_enable(FilteredAudioOutput &ao); void -ao_plugin_disable(AudioOutput &ao) noexcept; +ao_plugin_disable(FilteredAudioOutput &ao) noexcept; void -ao_plugin_open(AudioOutput &ao, AudioFormat &audio_format); +ao_plugin_open(FilteredAudioOutput &ao, AudioFormat &audio_format); void -ao_plugin_close(AudioOutput &ao) noexcept; +ao_plugin_close(FilteredAudioOutput &ao) noexcept; gcc_pure std::chrono::steady_clock::duration -ao_plugin_delay(AudioOutput &ao) noexcept; +ao_plugin_delay(FilteredAudioOutput &ao) noexcept; void -ao_plugin_send_tag(AudioOutput &ao, const Tag &tag); +ao_plugin_send_tag(FilteredAudioOutput &ao, const Tag &tag); size_t -ao_plugin_play(AudioOutput &ao, const void *chunk, size_t size); +ao_plugin_play(FilteredAudioOutput &ao, const void *chunk, size_t size); void -ao_plugin_drain(AudioOutput &ao); +ao_plugin_drain(FilteredAudioOutput &ao); void -ao_plugin_cancel(AudioOutput &ao) noexcept; +ao_plugin_cancel(FilteredAudioOutput &ao) noexcept; bool -ao_plugin_pause(AudioOutput &ao); +ao_plugin_pause(FilteredAudioOutput &ao); #endif diff --git a/src/output/Wrapper.hxx b/src/output/Wrapper.hxx index d7ef31166..f5a09afe7 100644 --- a/src/output/Wrapper.hxx +++ b/src/output/Wrapper.hxx @@ -30,68 +30,68 @@ struct Tag; template struct AudioOutputWrapper { - static T &Cast(AudioOutput &ao) { + static T &Cast(FilteredAudioOutput &ao) { return ContainerCast(ao, &T::base); } - static AudioOutput *Init(EventLoop &event_loop, - const ConfigBlock &block) { + static FilteredAudioOutput *Init(EventLoop &event_loop, + const ConfigBlock &block) { T *t = T::Create(event_loop, block); return &t->base; } - static void Finish(AudioOutput *ao) { + static void Finish(FilteredAudioOutput *ao) { T *t = &Cast(*ao); delete t; } - static void Enable(AudioOutput *ao) { + static void Enable(FilteredAudioOutput *ao) { T &t = Cast(*ao); t.Enable(); } - static void Disable(AudioOutput *ao) { + static void Disable(FilteredAudioOutput *ao) { T &t = Cast(*ao); t.Disable(); } - static void Open(AudioOutput *ao, AudioFormat &audio_format) { + static void Open(FilteredAudioOutput *ao, AudioFormat &audio_format) { T &t = Cast(*ao); t.Open(audio_format); } - static void Close(AudioOutput *ao) { + static void Close(FilteredAudioOutput *ao) { T &t = Cast(*ao); t.Close(); } gcc_pure - static std::chrono::steady_clock::duration Delay(AudioOutput *ao) noexcept { + static std::chrono::steady_clock::duration Delay(FilteredAudioOutput *ao) noexcept { T &t = Cast(*ao); return t.Delay(); } - static void SendTag(AudioOutput *ao, const Tag &tag) { + static void SendTag(FilteredAudioOutput *ao, const Tag &tag) { T &t = Cast(*ao); t.SendTag(tag); } - static size_t Play(AudioOutput *ao, const void *chunk, size_t size) { + static size_t Play(FilteredAudioOutput *ao, const void *chunk, size_t size) { T &t = Cast(*ao); return t.Play(chunk, size); } - static void Drain(AudioOutput *ao) { + static void Drain(FilteredAudioOutput *ao) { T &t = Cast(*ao); t.Drain(); } - static void Cancel(AudioOutput *ao) { + static void Cancel(FilteredAudioOutput *ao) { T &t = Cast(*ao); t.Cancel(); } - static bool Pause(AudioOutput *ao) { + static bool Pause(FilteredAudioOutput *ao) { T &t = Cast(*ao); return t.Pause(); } diff --git a/src/output/plugins/AlsaOutputPlugin.cxx b/src/output/plugins/AlsaOutputPlugin.cxx index 9fe0a3dd1..1d3d24869 100644 --- a/src/output/plugins/AlsaOutputPlugin.cxx +++ b/src/output/plugins/AlsaOutputPlugin.cxx @@ -64,7 +64,7 @@ class AlsaOutput final friend struct AudioOutputWrapper; - AudioOutput base; + FilteredAudioOutput base; Manual pcm_export; diff --git a/src/output/plugins/AoOutputPlugin.cxx b/src/output/plugins/AoOutputPlugin.cxx index b131e8994..0be06acd0 100644 --- a/src/output/plugins/AoOutputPlugin.cxx +++ b/src/output/plugins/AoOutputPlugin.cxx @@ -40,7 +40,7 @@ static unsigned ao_output_ref; class AoOutput { friend struct AudioOutputWrapper; - AudioOutput base; + FilteredAudioOutput base; const size_t write_size; int driver; diff --git a/src/output/plugins/FifoOutputPlugin.cxx b/src/output/plugins/FifoOutputPlugin.cxx index a57fd44b8..c001e2195 100644 --- a/src/output/plugins/FifoOutputPlugin.cxx +++ b/src/output/plugins/FifoOutputPlugin.cxx @@ -37,7 +37,7 @@ class FifoOutput { friend struct AudioOutputWrapper; - AudioOutput base; + FilteredAudioOutput base; const AllocatedPath path; std::string path_utf8; diff --git a/src/output/plugins/HaikuOutputPlugin.cxx b/src/output/plugins/HaikuOutputPlugin.cxx index ecf37c897..d6b8c5b2e 100644 --- a/src/output/plugins/HaikuOutputPlugin.cxx +++ b/src/output/plugins/HaikuOutputPlugin.cxx @@ -48,7 +48,7 @@ class HaikuOutput { friend int haiku_output_get_volume(HaikuOutput &haiku); friend bool haiku_output_set_volume(HaikuOutput &haiku, unsigned volume); - AudioOutput base; + FilteredAudioOutput base; size_t write_size; diff --git a/src/output/plugins/JackOutputPlugin.cxx b/src/output/plugins/JackOutputPlugin.cxx index 4abc4b057..770de3fdb 100644 --- a/src/output/plugins/JackOutputPlugin.cxx +++ b/src/output/plugins/JackOutputPlugin.cxx @@ -43,7 +43,7 @@ static constexpr unsigned MAX_PORTS = 16; static constexpr size_t jack_sample_size = sizeof(jack_default_audio_sample_t); struct JackOutput { - AudioOutput base; + FilteredAudioOutput base; /** * libjack options passed to jack_client_open(). @@ -443,7 +443,7 @@ JackOutput::Disable() } } -static AudioOutput * +static FilteredAudioOutput * mpd_jack_init(EventLoop &, const ConfigBlock &block) { jack_set_error_function(mpd_jack_error); diff --git a/src/output/plugins/NullOutputPlugin.cxx b/src/output/plugins/NullOutputPlugin.cxx index 1090f62b5..4603e16df 100644 --- a/src/output/plugins/NullOutputPlugin.cxx +++ b/src/output/plugins/NullOutputPlugin.cxx @@ -26,7 +26,7 @@ class NullOutput { friend struct AudioOutputWrapper; - AudioOutput base; + FilteredAudioOutput base; const bool sync; diff --git a/src/output/plugins/OSXOutputPlugin.cxx b/src/output/plugins/OSXOutputPlugin.cxx index c68deb88b..c619d2ec5 100644 --- a/src/output/plugins/OSXOutputPlugin.cxx +++ b/src/output/plugins/OSXOutputPlugin.cxx @@ -36,7 +36,7 @@ #include struct OSXOutput { - AudioOutput base; + FilteredAudioOutput base; /* configuration settings */ OSType component_subtype; @@ -103,7 +103,7 @@ OSXOutput::OSXOutput(const ConfigBlock &block) sync_sample_rate = block.GetBlockValue("sync_sample_rate", false); } -static AudioOutput * +static FilteredAudioOutput * osx_output_init(EventLoop &, const ConfigBlock &block) { OSXOutput *oo = new OSXOutput(block); @@ -128,7 +128,7 @@ osx_output_init(EventLoop &, const ConfigBlock &block) } static void -osx_output_finish(AudioOutput *ao) +osx_output_finish(FilteredAudioOutput *ao) { OSXOutput *oo = (OSXOutput *)ao; @@ -514,7 +514,7 @@ osx_render(void *vdata, } static void -osx_output_enable(AudioOutput *ao) +osx_output_enable(FilteredAudioOutput *ao) { char errormsg[1024]; OSXOutput *oo = (OSXOutput *)ao; @@ -550,7 +550,7 @@ osx_output_enable(AudioOutput *ao) } static void -osx_output_disable(AudioOutput *ao) +osx_output_disable(FilteredAudioOutput *ao) { OSXOutput *oo = (OSXOutput *)ao; @@ -562,7 +562,7 @@ osx_output_disable(AudioOutput *ao) } static void -osx_output_close(AudioOutput *ao) +osx_output_close(FilteredAudioOutput *ao) { OSXOutput *od = (OSXOutput *)ao; @@ -573,7 +573,7 @@ osx_output_close(AudioOutput *ao) } static void -osx_output_open(AudioOutput *ao, AudioFormat &audio_format) +osx_output_open(FilteredAudioOutput *ao, AudioFormat &audio_format) { char errormsg[1024]; OSXOutput *od = (OSXOutput *)ao; @@ -663,14 +663,14 @@ osx_output_open(AudioOutput *ao, AudioFormat &audio_format) } static size_t -osx_output_play(AudioOutput *ao, const void *chunk, size_t size) +osx_output_play(FilteredAudioOutput *ao, const void *chunk, size_t size) { OSXOutput *od = (OSXOutput *)ao; return od->ring_buffer->push((uint8_t *)chunk, size); } static std::chrono::steady_clock::duration -osx_output_delay(AudioOutput *ao) noexcept +osx_output_delay(FilteredAudioOutput *ao) noexcept { OSXOutput *od = (OSXOutput *)ao; return od->ring_buffer->write_available() diff --git a/src/output/plugins/OpenALOutputPlugin.cxx b/src/output/plugins/OpenALOutputPlugin.cxx index 4f31ad4ee..79d7c165e 100644 --- a/src/output/plugins/OpenALOutputPlugin.cxx +++ b/src/output/plugins/OpenALOutputPlugin.cxx @@ -39,7 +39,7 @@ class OpenALOutput { /* should be enough for buffer size = 2048 */ static constexpr unsigned NUM_BUFFERS = 16; - AudioOutput base; + FilteredAudioOutput base; const char *device_name; ALCdevice *device; diff --git a/src/output/plugins/OssOutputPlugin.cxx b/src/output/plugins/OssOutputPlugin.cxx index 60237a537..b5fe87461 100644 --- a/src/output/plugins/OssOutputPlugin.cxx +++ b/src/output/plugins/OssOutputPlugin.cxx @@ -63,7 +63,7 @@ class OssOutput { friend struct AudioOutputWrapper; - AudioOutput base; + FilteredAudioOutput base; #ifdef AFMT_S24_PACKED Manual pcm_export; diff --git a/src/output/plugins/PipeOutputPlugin.cxx b/src/output/plugins/PipeOutputPlugin.cxx index 7d5efb940..455b16fab 100644 --- a/src/output/plugins/PipeOutputPlugin.cxx +++ b/src/output/plugins/PipeOutputPlugin.cxx @@ -31,7 +31,7 @@ class PipeOutput { friend struct AudioOutputWrapper; - AudioOutput base; + FilteredAudioOutput base; const std::string cmd; FILE *fh; diff --git a/src/output/plugins/PulseOutputPlugin.cxx b/src/output/plugins/PulseOutputPlugin.cxx index cae66eb36..cd1f4c97b 100644 --- a/src/output/plugins/PulseOutputPlugin.cxx +++ b/src/output/plugins/PulseOutputPlugin.cxx @@ -47,7 +47,7 @@ class PulseOutput { friend struct AudioOutputWrapper; - AudioOutput base; + FilteredAudioOutput base; const char *name; const char *server; diff --git a/src/output/plugins/RecorderOutputPlugin.cxx b/src/output/plugins/RecorderOutputPlugin.cxx index 75705a609..075abf472 100644 --- a/src/output/plugins/RecorderOutputPlugin.cxx +++ b/src/output/plugins/RecorderOutputPlugin.cxx @@ -45,7 +45,7 @@ static constexpr Domain recorder_domain("recorder"); class RecorderOutput { friend struct AudioOutputWrapper; - AudioOutput base; + FilteredAudioOutput base; /** * The configured encoder plugin. diff --git a/src/output/plugins/RoarOutputPlugin.cxx b/src/output/plugins/RoarOutputPlugin.cxx index 15bd031f0..4963cf9f7 100644 --- a/src/output/plugins/RoarOutputPlugin.cxx +++ b/src/output/plugins/RoarOutputPlugin.cxx @@ -39,7 +39,7 @@ class RoarOutput { friend struct AudioOutputWrapper; - AudioOutput base; + FilteredAudioOutput base; const std::string host, name; @@ -54,7 +54,7 @@ class RoarOutput { public: RoarOutput(const ConfigBlock &block); - operator AudioOutput *() { + operator FilteredAudioOutput *() { return &base; } diff --git a/src/output/plugins/ShoutOutputPlugin.cxx b/src/output/plugins/ShoutOutputPlugin.cxx index 847ab3b95..4126059b7 100644 --- a/src/output/plugins/ShoutOutputPlugin.cxx +++ b/src/output/plugins/ShoutOutputPlugin.cxx @@ -40,7 +40,7 @@ static constexpr unsigned DEFAULT_CONN_TIMEOUT = 2; struct ShoutOutput final { - AudioOutput base; + FilteredAudioOutput base; shout_t *shout_conn; shout_metadata_t *shout_meta; diff --git a/src/output/plugins/SndioOutputPlugin.cxx b/src/output/plugins/SndioOutputPlugin.cxx index f8c154c1a..a0d7a3e48 100644 --- a/src/output/plugins/SndioOutputPlugin.cxx +++ b/src/output/plugins/SndioOutputPlugin.cxx @@ -47,7 +47,7 @@ static constexpr Domain sndio_output_domain("sndio_output"); class SndioOutput { friend struct AudioOutputWrapper; - AudioOutput base; + FilteredAudioOutput base; const char *const device; const unsigned buffer_time; /* in ms */ struct sio_hdl *sio_hdl; diff --git a/src/output/plugins/SolarisOutputPlugin.cxx b/src/output/plugins/SolarisOutputPlugin.cxx index 856a64ac0..ae4e71ff8 100644 --- a/src/output/plugins/SolarisOutputPlugin.cxx +++ b/src/output/plugins/SolarisOutputPlugin.cxx @@ -53,7 +53,7 @@ struct audio_info { class SolarisOutput { friend struct AudioOutputWrapper; - AudioOutput base; + FilteredAudioOutput base; /* configuration */ const char *const device; diff --git a/src/output/plugins/WinmmOutputPlugin.cxx b/src/output/plugins/WinmmOutputPlugin.cxx index b17c65d3f..0a335eeaf 100644 --- a/src/output/plugins/WinmmOutputPlugin.cxx +++ b/src/output/plugins/WinmmOutputPlugin.cxx @@ -42,7 +42,7 @@ struct WinmmBuffer { class WinmmOutput { friend struct AudioOutputWrapper; - AudioOutput base; + FilteredAudioOutput base; const UINT device_id; HWAVEOUT handle; diff --git a/src/output/plugins/httpd/HttpdInternal.hxx b/src/output/plugins/httpd/HttpdInternal.hxx index 11d193d56..7726ea2c1 100644 --- a/src/output/plugins/httpd/HttpdInternal.hxx +++ b/src/output/plugins/httpd/HttpdInternal.hxx @@ -52,7 +52,7 @@ struct Tag; class HttpdOutput final : ServerSocket, DeferredMonitor { friend struct AudioOutputWrapper; - AudioOutput base; + FilteredAudioOutput base; /** * True if the audio output is open and accepts client @@ -160,7 +160,7 @@ public: static HttpdOutput *Create(EventLoop &event_loop, const ConfigBlock &block); - static constexpr HttpdOutput *Cast(AudioOutput *ao) { + static constexpr HttpdOutput *Cast(FilteredAudioOutput *ao) { return &ContainerCast(*ao, &HttpdOutput::base); } diff --git a/src/output/plugins/sles/SlesOutputPlugin.cxx b/src/output/plugins/sles/SlesOutputPlugin.cxx index 4165dd20f..ca47f99a4 100644 --- a/src/output/plugins/sles/SlesOutputPlugin.cxx +++ b/src/output/plugins/sles/SlesOutputPlugin.cxx @@ -43,7 +43,7 @@ class SlesOutput { static constexpr unsigned N_BUFFERS = 3; static constexpr size_t BUFFER_SIZE = 65536; - AudioOutput base; + FilteredAudioOutput base; SLES::Object engine_object, mix_object, play_object; SLES::Play play; @@ -89,7 +89,7 @@ class SlesOutput { public: SlesOutput(const ConfigBlock &block); - operator AudioOutput *() { + operator FilteredAudioOutput *() { return &base; } diff --git a/test/read_mixer.cxx b/test/read_mixer.cxx index 4c7efabe3..f133e426d 100644 --- a/test/read_mixer.cxx +++ b/test/read_mixer.cxx @@ -51,7 +51,7 @@ try { EventLoop event_loop; Mixer *mixer = mixer_new(event_loop, alsa_mixer_plugin, - *(AudioOutput *)nullptr, + *(FilteredAudioOutput *)nullptr, *(MixerListener *)nullptr, ConfigBlock()); diff --git a/test/run_output.cxx b/test/run_output.cxx index 9f6a87a60..f3e969fd8 100644 --- a/test/run_output.cxx +++ b/test/run_output.cxx @@ -49,7 +49,7 @@ filter_plugin_by_name(gcc_unused const char *name) noexcept return NULL; } -static AudioOutput * +static FilteredAudioOutput * load_audio_output(EventLoop &event_loop, const char *name) { const auto *param = config_find_block(ConfigBlockOption::AUDIO_OUTPUT, @@ -63,7 +63,7 @@ load_audio_output(EventLoop &event_loop, const char *name) } static void -run_output(AudioOutput &ao, AudioFormat audio_format) +run_output(FilteredAudioOutput &ao, AudioFormat audio_format) { /* open the audio output */ @@ -127,7 +127,7 @@ try { /* initialize the audio output */ - AudioOutput *ao = load_audio_output(io_thread.GetEventLoop(), argv[2]); + auto *ao = load_audio_output(io_thread.GetEventLoop(), argv[2]); /* parse the audio format */