diff options
author | Max Kellermann <max@duempel.org> | 2014-12-29 23:45:14 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2014-12-29 23:45:14 +0100 |
commit | 0b9f650fe27bcb5ff78928b059c2e5032cfbcb97 (patch) | |
tree | a64e6c31716cfff9a39eae58f970a3b4bb31f929 /src/output/plugins/RoarOutputPlugin.cxx | |
parent | 977834179a790e8573eb8cd12252e0c160b69bd7 (diff) | |
download | mpd-0b9f650fe27bcb5ff78928b059c2e5032cfbcb97.tar.gz mpd-0b9f650fe27bcb5ff78928b059c2e5032cfbcb97.tar.xz mpd-0b9f650fe27bcb5ff78928b059c2e5032cfbcb97.zip |
output/Wrapper: new helper class
Diffstat (limited to '')
-rw-r--r-- | src/output/plugins/RoarOutputPlugin.cxx | 54 |
1 files changed, 10 insertions, 44 deletions
diff --git a/src/output/plugins/RoarOutputPlugin.cxx b/src/output/plugins/RoarOutputPlugin.cxx index 87a3f4e8f..d478d08e0 100644 --- a/src/output/plugins/RoarOutputPlugin.cxx +++ b/src/output/plugins/RoarOutputPlugin.cxx @@ -21,6 +21,7 @@ #include "config.h" #include "RoarOutputPlugin.hxx" #include "../OutputAPI.hxx" +#include "../Wrapper.hxx" #include "mixer/MixerList.hxx" #include "thread/Mutex.hxx" #include "util/Error.hxx" @@ -36,6 +37,8 @@ #undef new class RoarOutput { + friend struct AudioOutputWrapper<RoarOutput>; + AudioOutput base; std::string host, name; @@ -147,14 +150,6 @@ roar_init(const config_param ¶m, Error &error) } static void -roar_finish(AudioOutput *ao) -{ - RoarOutput *self = (RoarOutput *)ao; - - delete self; -} - -static void roar_use_audio_format(struct roar_audio_info *info, AudioFormat &audio_format) { @@ -221,14 +216,6 @@ RoarOutput::Open(AudioFormat &audio_format, Error &error) return true; } -static bool -roar_open(AudioOutput *ao, AudioFormat &audio_format, Error &error) -{ - RoarOutput *self = (RoarOutput *)ao; - - return self->Open(audio_format, error); -} - inline void RoarOutput::Close() { @@ -242,13 +229,6 @@ RoarOutput::Close() roar_disconnect(&con); } -static void -roar_close(AudioOutput *ao) -{ - RoarOutput *self = (RoarOutput *)ao; - self->Close(); -} - inline void RoarOutput::Cancel() { @@ -277,14 +257,6 @@ RoarOutput::Cancel() alive = true; } -static void -roar_cancel(AudioOutput *ao) -{ - RoarOutput *self = (RoarOutput *)ao; - - self->Cancel(); -} - inline size_t RoarOutput::Play(const void *chunk, size_t size, Error &error) { @@ -302,14 +274,6 @@ RoarOutput::Play(const void *chunk, size_t size, Error &error) return nbytes; } -static size_t -roar_play(AudioOutput *ao, const void *chunk, size_t size, - Error &error) -{ - RoarOutput *self = (RoarOutput *)ao; - return self->Play(chunk, size, error); -} - static const char* roar_tag_convert(TagType type, bool *is_uuid) { @@ -413,20 +377,22 @@ roar_send_tag(AudioOutput *ao, const Tag &meta) self->SendTag(meta); } +typedef AudioOutputWrapper<RoarOutput> Wrapper; + const struct AudioOutputPlugin roar_output_plugin = { "roar", nullptr, roar_init, - roar_finish, + &Wrapper::Finish, nullptr, nullptr, - roar_open, - roar_close, + &Wrapper::Open, + &Wrapper::Close, nullptr, roar_send_tag, - roar_play, + &Wrapper::Play, nullptr, - roar_cancel, + &Wrapper::Cancel, nullptr, &roar_mixer_plugin, }; |