From 2308eda2b8de54003372feb9d3c3a424d97621e7 Mon Sep 17 00:00:00 2001 From: wm4 Date: Mon, 15 Sep 2014 20:37:07 +0200 Subject: ao_oss: don't use SNDCTL_DSP_RESET when pausing on NetBSD It seems on NetBSD SNDCTL_DSP_RESET exists, but using it for pausing is not feasible. We still use it to discard the audio buffer when closing the audio device. --- audio/out/ao_oss.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'audio') diff --git a/audio/out/ao_oss.c b/audio/out/ao_oss.c index e77c2bc4e6..28582b2d85 100644 --- a/audio/out/ao_oss.c +++ b/audio/out/ao_oss.c @@ -53,6 +53,11 @@ #include "ao.h" #include "internal.h" +// Define to 0 if the device must be reopened to reset it (stop all playback, +// clear the buffer), and the device should be closed when unused. +// Define to 1 if SNDCTL_DSP_RESET should be used to reset without close. +#define KEEP_DEVICE (defined(SNDCTL_DSP_RESET) && !defined(__NetBSD__)) + struct priv { int audio_fd; int prepause_space; @@ -234,7 +239,7 @@ static void uninit(struct ao *ao) struct priv *p = ao->priv; if (p->audio_fd == -1) return; -#ifdef SNDCTL_DSP_RESET +#if defined(SNDCTL_DSP_RESET) ioctl(p->audio_fd, SNDCTL_DSP_RESET, NULL); #endif close(p->audio_fd); @@ -454,7 +459,7 @@ static void drain(struct ao *ao) #endif } -#ifndef SNDCTL_DSP_RESET +#if !KEEP_DEVICE static void close_device(struct ao *ao) { struct priv *p = ao->priv; @@ -468,7 +473,7 @@ static void reset(struct ao *ao) { struct priv *p = ao->priv; int oss_format; -#ifdef SNDCTL_DSP_RESET +#if KEEP_DEVICE ioctl(p->audio_fd, SNDCTL_DSP_RESET, NULL); #else close_device(ao); @@ -518,7 +523,7 @@ static void audio_pause(struct ao *ao) { struct priv *p = ao->priv; p->prepause_space = get_space(ao) * ao->sstride; -#ifdef SNDCTL_DSP_RESET +#if KEEP_DEVICE ioctl(p->audio_fd, SNDCTL_DSP_RESET, NULL); #else close_device(ao); @@ -546,7 +551,7 @@ static int play(struct ao *ao, void **data, int samples, int flags) static void audio_resume(struct ao *ao) { struct priv *p = ao->priv; -#ifndef SNDCTL_DSP_RESET +#if !KEEP_DEVICE reset(ao); #endif int fillframes = get_space(ao) - p->prepause_space / ao->sstride; -- cgit v1.2.3