input/alsa: use the EventLoop& passed to init() instead of io_thread_get()

This commit is contained in:
Max Kellermann 2017-02-10 22:07:13 +01:00
parent 835136dcd3
commit 87c9856b20

View File

@ -39,7 +39,6 @@
#include "Log.hxx"
#include "event/MultiSocketMonitor.hxx"
#include "event/DeferredMonitor.hxx"
#include "IOThread.hxx"
#include <alsa/asoundlib.h>
@ -107,7 +106,8 @@ public:
snd_pcm_close(capture_handle);
}
static InputStream *Create(const char *uri, Mutex &mutex, Cond &cond);
static InputStream *Create(EventLoop &event_loop, const char *uri,
Mutex &mutex, Cond &cond);
protected:
/* virtual methods from AsyncInputStream */
@ -146,7 +146,8 @@ private:
};
inline InputStream *
AlsaInputStream::Create(const char *uri, Mutex &mutex, Cond &cond)
AlsaInputStream::Create(EventLoop &event_loop, const char *uri,
Mutex &mutex, Cond &cond)
{
const char *device = StringAfterPrefix(uri, "alsa://");
if (device == nullptr)
@ -165,7 +166,7 @@ AlsaInputStream::Create(const char *uri, Mutex &mutex, Cond &cond)
snd_pcm_t *handle = OpenDevice(device, rate, format, channels);
int frame_size = snd_pcm_format_width(format) / 8 * channels;
return new AlsaInputStream(io_thread_get(),
return new AlsaInputStream(event_loop,
uri, mutex, cond,
device, handle, frame_size);
}
@ -386,15 +387,24 @@ AlsaInputStream::OpenDevice(const char *device,
/*######################### Plugin Functions ##############################*/
static EventLoop *alsa_input_event_loop;
static void
alsa_input_init(EventLoop &event_loop, const ConfigBlock &)
{
alsa_input_event_loop = &event_loop;
}
static InputStream *
alsa_input_open(const char *uri, Mutex &mutex, Cond &cond)
{
return AlsaInputStream::Create(uri, mutex, cond);
return AlsaInputStream::Create(*alsa_input_event_loop, uri,
mutex, cond);
}
const struct InputPlugin input_plugin_alsa = {
"alsa",
nullptr,
alsa_input_init,
nullptr,
alsa_input_open,
};