From a54b99d1e5871d7962956a67411f17d9fdbe8680 Mon Sep 17 00:00:00 2001 From: wm4 Date: Thu, 6 Nov 2014 01:17:36 +0100 Subject: ao_oss: wait for events with poll() The intention is to avoid using the timeout-based fallback. There's some minor hope that this will help with OpenBSD (see #1239), although it probably won't. Some chance that this will cause trouble with obscure OSS implementations or emulations. --- audio/out/ao_oss.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/audio/out/ao_oss.c b/audio/out/ao_oss.c index 77ae374611..08266d96ce 100644 --- a/audio/out/ao_oss.c +++ b/audio/out/ao_oss.c @@ -616,6 +616,17 @@ static void audio_resume(struct ao *ao) ao_play_silence(ao, p->prepause_samples); } +static int audio_wait(struct ao *ao, pthread_mutex_t *lock) +{ + struct priv *p = ao->priv; + + struct pollfd fd = {.fd = p->audio_fd, .events = POLLOUT}; + int r = ao_wait_poll(ao, &fd, 1, lock); + if (fd.revents & (POLLERR | POLLNVAL)) + return -1; + return r; +} + #define OPT_BASE_STRUCT struct priv const struct ao_driver audio_out_oss = { @@ -631,6 +642,8 @@ const struct ao_driver audio_out_oss = { .resume = audio_resume, .reset = reset, .drain = drain, + .wait = audio_wait, + .wakeup = ao_wakeup_poll, .priv_size = sizeof(struct priv), .priv_defaults = &(const struct priv) { .audio_fd = -1, -- cgit v1.2.3