output/Plugin: pass EventLoop& to init()

Eliminate dependency on io_thread_get().
This commit is contained in:
Max Kellermann 2017-01-25 09:47:43 +01:00
parent d3f35dab1e
commit 8fd9d91974
24 changed files with 58 additions and 42 deletions

View File

@ -295,7 +295,7 @@ audio_output_new(EventLoop &event_loop,
plugin->name);
}
AudioOutput *ao = ao_plugin_init(*plugin, block);
AudioOutput *ao = ao_plugin_init(event_loop, *plugin, block);
assert(ao != nullptr);
try {

View File

@ -22,12 +22,13 @@
#include "Internal.hxx"
AudioOutput *
ao_plugin_init(const AudioOutputPlugin &plugin,
ao_plugin_init(EventLoop &event_loop,
const AudioOutputPlugin &plugin,
const ConfigBlock &block)
{
assert(plugin.init != nullptr);
return plugin.init(block);
return plugin.init(event_loop, block);
}
void

View File

@ -31,6 +31,7 @@ struct AudioFormat;
struct Tag;
struct AudioOutput;
struct MixerPlugin;
class EventLoop;
/**
* A plugin which controls an audio output device.
@ -56,7 +57,7 @@ struct AudioOutputPlugin {
* @param param the configuration section, or nullptr if there is
* no configuration
*/
AudioOutput *(*init)(const ConfigBlock &block);
AudioOutput *(*init)(EventLoop &event_loop, const ConfigBlock &block);
/**
* Free resources allocated by this device.
@ -162,7 +163,8 @@ ao_plugin_test_default_device(const AudioOutputPlugin *plugin)
gcc_malloc
AudioOutput *
ao_plugin_init(const AudioOutputPlugin &plugin,
ao_plugin_init(EventLoop &event_loop,
const AudioOutputPlugin &plugin,
const ConfigBlock &block);
void

View File

@ -33,8 +33,9 @@ struct AudioOutputWrapper {
return ContainerCast(ao, &T::base);
}
static AudioOutput *Init(const ConfigBlock &block) {
T *t = T::Create(block);
static AudioOutput *Init(EventLoop &event_loop,
const ConfigBlock &block) {
T *t = T::Create(event_loop, block);
return &t->base;
}

View File

@ -136,7 +136,8 @@ public:
return device.empty() ? default_device : device.c_str();
}
static AlsaOutput *Create(const ConfigBlock &block);
static AlsaOutput *Create(EventLoop &event_loop,
const ConfigBlock &block);
void Enable();
void Disable();
@ -207,7 +208,7 @@ AlsaOutput::AlsaOutput(const ConfigBlock &block)
}
inline AlsaOutput *
AlsaOutput::Create(const ConfigBlock &block)
AlsaOutput::Create(EventLoop &, const ConfigBlock &block)
{
return new AlsaOutput(block);
}

View File

@ -51,7 +51,7 @@ class AoOutput {
~AoOutput();
public:
static AoOutput *Create(const ConfigBlock &block) {
static AoOutput *Create(EventLoop &, const ConfigBlock &block) {
return new AoOutput(block);
}

View File

@ -54,7 +54,8 @@ public:
CloseFifo();
}
static FifoOutput *Create(const ConfigBlock &block);
static FifoOutput *Create(EventLoop &event_loop,
const ConfigBlock &block);
void Create();
void Check();
@ -169,7 +170,7 @@ try {
}
inline FifoOutput *
FifoOutput::Create(const ConfigBlock &block)
FifoOutput::Create(EventLoop &, const ConfigBlock &block)
{
return new FifoOutput(block);
}

View File

@ -71,7 +71,8 @@ public:
~HaikuOutput();
static HaikuOutput *Create(const ConfigBlock &block);
static HaikuOutput *Create(EventLoop &event_loop,
const ConfigBlock &block);
void Open(AudioFormat &audio_format);
void Close();
@ -119,7 +120,7 @@ haiku_test_default_device(void)
}
inline HaikuOutput *
HaikuOutput::Create(const ConfigBlock &block)
HaikuOutput::Create(EventLoop &, const ConfigBlock &block)
{
initialize_application();

View File

@ -444,7 +444,7 @@ JackOutput::Disable()
}
static AudioOutput *
mpd_jack_init(const ConfigBlock &block)
mpd_jack_init(EventLoop &, const ConfigBlock &block)
{
jack_set_error_function(mpd_jack_error);

View File

@ -37,7 +37,8 @@ public:
:base(null_output_plugin, block),
sync(block.GetBlockValue("sync", true)) {}
static NullOutput *Create(const ConfigBlock &block);
static NullOutput *Create(EventLoop &event_loop,
const ConfigBlock &block);
void Open(AudioFormat &audio_format) {
if (sync)
@ -72,7 +73,7 @@ public:
};
inline NullOutput *
NullOutput::Create(const ConfigBlock &block)
NullOutput::Create(EventLoop &, const ConfigBlock &block)
{
return new NullOutput(block);
}

View File

@ -104,7 +104,7 @@ OSXOutput::OSXOutput(const ConfigBlock &block)
}
static AudioOutput *
osx_output_init(const ConfigBlock &block)
osx_output_init(EventLoop &, const ConfigBlock &block)
{
OSXOutput *oo = new OSXOutput(block);

View File

@ -52,7 +52,8 @@ class OpenALOutput {
OpenALOutput(const ConfigBlock &block);
static OpenALOutput *Create(const ConfigBlock &block);
static OpenALOutput *Create(EventLoop &event_loop,
const ConfigBlock &block);
void Open(AudioFormat &audio_format);
void Close();
@ -146,7 +147,7 @@ OpenALOutput::OpenALOutput(const ConfigBlock &block)
}
inline OpenALOutput *
OpenALOutput::Create(const ConfigBlock &block)
OpenALOutput::Create(EventLoop &, const ConfigBlock &block)
{
return new OpenALOutput(block);
}

View File

@ -89,7 +89,8 @@ public:
:base(oss_output_plugin, block),
fd(-1), device(_device) {}
static OssOutput *Create(const ConfigBlock &block);
static OssOutput *Create(EventLoop &event_loop,
const ConfigBlock &block);
#ifdef AFMT_S24_PACKED
void Enable() {
@ -226,7 +227,7 @@ oss_open_default()
}
inline OssOutput *
OssOutput::Create(const ConfigBlock &block)
OssOutput::Create(EventLoop &, const ConfigBlock &block)
{
const char *device = block.GetBlockValue("device");
if (device != nullptr)

View File

@ -39,7 +39,8 @@ class PipeOutput {
PipeOutput(const ConfigBlock &block);
public:
static PipeOutput *Create(const ConfigBlock &block);
static PipeOutput *Create(EventLoop &event_loop,
const ConfigBlock &block);
void Open(AudioFormat &audio_format);
@ -59,7 +60,7 @@ PipeOutput::PipeOutput(const ConfigBlock &block)
}
inline PipeOutput *
PipeOutput::Create(const ConfigBlock &block)
PipeOutput::Create(EventLoop &, const ConfigBlock &block)
{
return new PipeOutput(block);
}

View File

@ -93,7 +93,8 @@ public:
gcc_const
static bool TestDefaultDevice();
static PulseOutput *Create(const ConfigBlock &block);
static PulseOutput *Create(EventLoop &event_loop,
const ConfigBlock &block);
void Enable();
void Disable();
@ -415,7 +416,7 @@ PulseOutput::SetupContext()
}
PulseOutput *
PulseOutput::Create(const ConfigBlock &block)
PulseOutput::Create(EventLoop &, const ConfigBlock &block)
{
return new PulseOutput(block);
}

View File

@ -81,7 +81,8 @@ class RecorderOutput {
delete prepared_encoder;
}
static RecorderOutput *Create(const ConfigBlock &block);
static RecorderOutput *Create(EventLoop &event_loop,
const ConfigBlock &block);
void Open(AudioFormat &audio_format);
void Close();
@ -141,7 +142,7 @@ RecorderOutput::RecorderOutput(const ConfigBlock &block)
}
RecorderOutput *
RecorderOutput::Create(const ConfigBlock &block)
RecorderOutput::Create(EventLoop &, const ConfigBlock &block)
{
return new RecorderOutput(block);
}

View File

@ -58,7 +58,7 @@ public:
return &base;
}
static RoarOutput *Create(const ConfigBlock &block) {
static RoarOutput *Create(EventLoop &, const ConfigBlock &block) {
return new RoarOutput(block);
}

View File

@ -58,7 +58,8 @@ struct ShoutOutput final {
explicit ShoutOutput(const ConfigBlock &block);
~ShoutOutput();
static ShoutOutput *Create(const ConfigBlock &block);
static ShoutOutput *Create(EventLoop &event_loop,
const ConfigBlock &block);
void Open(AudioFormat &audio_format);
void Close();
@ -246,7 +247,7 @@ ShoutOutput::~ShoutOutput()
}
ShoutOutput *
ShoutOutput::Create(const ConfigBlock &block)
ShoutOutput::Create(EventLoop &, const ConfigBlock &block)
{
if (shout_init_count == 0)
shout_init();

View File

@ -47,7 +47,8 @@ class SndioOutput {
public:
SndioOutput(const ConfigBlock &block);
static SndioOutput *Create(const ConfigBlock &block);
static SndioOutput *Create(EventLoop &event_loop,
const ConfigBlock &block);
void Open(AudioFormat &audio_format);
void Close();
@ -64,7 +65,7 @@ SndioOutput::SndioOutput(const ConfigBlock &block)
}
SndioOutput *
SndioOutput::Create(const ConfigBlock &block)
SndioOutput::Create(EventLoop &, const ConfigBlock &block)
{
return new SndioOutput(block);
}

View File

@ -65,7 +65,7 @@ class SolarisOutput {
device(block.GetBlockValue("device", "/dev/audio")) {}
public:
static SolarisOutput *Create(const ConfigBlock &block) {
static SolarisOutput *Create(EventLoop &, const ConfigBlock &block) {
return new SolarisOutput(block);
}

View File

@ -63,7 +63,7 @@ public:
return handle;
}
static WinmmOutput *Create(const ConfigBlock &block) {
static WinmmOutput *Create(EventLoop &, const ConfigBlock &block) {
return new WinmmOutput(block);
}

View File

@ -155,7 +155,8 @@ public:
HttpdOutput(EventLoop &_loop, const ConfigBlock &block);
~HttpdOutput();
static HttpdOutput *Create(const ConfigBlock &block);
static HttpdOutput *Create(EventLoop &event_loop,
const ConfigBlock &block);
#if CLANG_OR_GCC_VERSION(4,7)
constexpr

View File

@ -30,7 +30,6 @@
#include "Page.hxx"
#include "IcyMetaDataServer.hxx"
#include "system/fd_util.h"
#include "IOThread.hxx"
#include "event/Call.hxx"
#include "util/RuntimeError.hxx"
#include "util/Domain.hxx"
@ -118,9 +117,9 @@ HttpdOutput::Unbind()
}
HttpdOutput *
HttpdOutput::Create(const ConfigBlock &block)
HttpdOutput::Create(EventLoop &event_loop, const ConfigBlock &block)
{
return new HttpdOutput(io_thread_get(), block);
return new HttpdOutput(event_loop, block);
}
/**
@ -466,7 +465,7 @@ HttpdOutput::CancelAllClients()
void
HttpdOutput::Cancel()
{
BlockingCall(io_thread_get(), [this](){
BlockingCall(GetEventLoop(), [this](){
CancelAllClients();
});
}

View File

@ -91,7 +91,8 @@ public:
return &base;
}
static SlesOutput *Create(const ConfigBlock &block);
static SlesOutput *Create(EventLoop &event_loop,
const ConfigBlock &block);
void Open(AudioFormat &audio_format);
void Close();
@ -413,7 +414,7 @@ sles_test_default_device()
}
inline SlesOutput *
SlesOutput::Create(const ConfigBlock &block)
SlesOutput::Create(EventLoop &, const ConfigBlock &block)
{
return new SlesOutput(block);
}