input/alsa: use the EventLoop& passed to init() instead of io_thread_get()
This commit is contained in:
parent
835136dcd3
commit
87c9856b20
@ -39,7 +39,6 @@
|
|||||||
#include "Log.hxx"
|
#include "Log.hxx"
|
||||||
#include "event/MultiSocketMonitor.hxx"
|
#include "event/MultiSocketMonitor.hxx"
|
||||||
#include "event/DeferredMonitor.hxx"
|
#include "event/DeferredMonitor.hxx"
|
||||||
#include "IOThread.hxx"
|
|
||||||
|
|
||||||
#include <alsa/asoundlib.h>
|
#include <alsa/asoundlib.h>
|
||||||
|
|
||||||
@ -107,7 +106,8 @@ public:
|
|||||||
snd_pcm_close(capture_handle);
|
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:
|
protected:
|
||||||
/* virtual methods from AsyncInputStream */
|
/* virtual methods from AsyncInputStream */
|
||||||
@ -146,7 +146,8 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
inline InputStream *
|
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://");
|
const char *device = StringAfterPrefix(uri, "alsa://");
|
||||||
if (device == nullptr)
|
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);
|
snd_pcm_t *handle = OpenDevice(device, rate, format, channels);
|
||||||
|
|
||||||
int frame_size = snd_pcm_format_width(format) / 8 * 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,
|
uri, mutex, cond,
|
||||||
device, handle, frame_size);
|
device, handle, frame_size);
|
||||||
}
|
}
|
||||||
@ -386,15 +387,24 @@ AlsaInputStream::OpenDevice(const char *device,
|
|||||||
|
|
||||||
/*######################### Plugin Functions ##############################*/
|
/*######################### 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 *
|
static InputStream *
|
||||||
alsa_input_open(const char *uri, Mutex &mutex, Cond &cond)
|
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 = {
|
const struct InputPlugin input_plugin_alsa = {
|
||||||
"alsa",
|
"alsa",
|
||||||
nullptr,
|
alsa_input_init,
|
||||||
nullptr,
|
nullptr,
|
||||||
alsa_input_open,
|
alsa_input_open,
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user