output/Wrapper: new helper class

This commit is contained in:
Max Kellermann
2014-12-29 23:45:14 +01:00
parent 977834179a
commit 0b9f650fe2
7 changed files with 160 additions and 256 deletions
+10 -44
View File
@@ -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;
@@ -146,14 +149,6 @@ roar_init(const config_param &param, Error &error)
return *self;
}
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,
};