summaryrefslogtreecommitdiffstats
path: root/src/modules/module-alsa-source.c
diff options
context:
space:
mode:
authorPierre Ossman <ossman@cendio.se>2006-02-26 19:09:26 +0000
committerPierre Ossman <ossman@cendio.se>2006-02-26 19:09:26 +0000
commitae07d5abd5fe680367723cc6913eb759d22d8551 (patch)
treea23e698b5f3b4058ecf1e53b9c5fb215706c6ede /src/modules/module-alsa-source.c
parentc119996c73e540f0c0579c3a6aa45b9cd27c2509 (diff)
Handle ALSA file descriptors more correctly. This means a bit more overhead,
but following their API properly should avoid problems in the future. git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@606 fefdeb5f-60dc-0310-8127-8f9354f1896f
Diffstat (limited to 'src/modules/module-alsa-source.c')
-rw-r--r--src/modules/module-alsa-source.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/modules/module-alsa-source.c b/src/modules/module-alsa-source.c
index a3570473..2adefa6a 100644
--- a/src/modules/module-alsa-source.c
+++ b/src/modules/module-alsa-source.c
@@ -57,8 +57,7 @@ struct userdata {
snd_mixer_t *mixer_handle;
snd_mixer_elem_t *mixer_elem;
pa_source *source;
- pa_io_event **io_events;
- unsigned n_io_events;
+ struct pa_alsa_fdlist *fdl;
long hw_volume_max, hw_volume_min;
size_t frame_size, fragment_size;
@@ -144,9 +143,9 @@ static void do_read(struct userdata *u) {
}
}
-static void io_callback(pa_mainloop_api*a, pa_io_event *e, PA_GCC_UNUSED int fd, PA_GCC_UNUSED pa_io_event_flags_t f, void *userdata) {
+static void fdl_callback(void *userdata) {
struct userdata *u = userdata;
- assert(u && a && e);
+ assert(u);
if (snd_pcm_state(u->pcm_handle) == SND_PCM_STATE_XRUN)
xrun_recovery(u);
@@ -350,8 +349,10 @@ int pa__init(pa_core *c, pa_module*m) {
pa_source_set_owner(u->source, m);
u->source->description = pa_sprintf_malloc("Advanced Linux Sound Architecture PCM on '%s'", dev);
- if (pa_create_io_events(u->pcm_handle, c->mainloop, &u->io_events, &u->n_io_events, io_callback, u) < 0) {
- pa_log(__FILE__": failed to obtain file descriptors");
+ u->fdl = pa_alsa_fdlist_new();
+ assert(u->fdl);
+ if (pa_alsa_fdlist_init_pcm(u->fdl, u->pcm_handle, c->mainloop, fdl_callback, u) < 0) {
+ pa_log(__FILE__": failed to initialise file descriptor monitoring");
goto fail;
}
@@ -399,8 +400,8 @@ void pa__done(pa_core *c, pa_module*m) {
pa_source_unref(u->source);
}
- if (u->io_events)
- pa_free_io_events(c->mainloop, u->io_events, u->n_io_events);
+ if (u->fdl)
+ pa_alsa_fdlist_free(u->fdl);
if (u->mixer_handle)
snd_mixer_close(u->mixer_handle);