summaryrefslogtreecommitdiffstats
path: root/audio
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-09-15 20:37:07 +0200
committerwm4 <wm4@nowhere>2014-09-15 21:54:28 +0200
commit2308eda2b8de54003372feb9d3c3a424d97621e7 (patch)
tree0d1d6d5638acb2134e0e1c44ee5a11ab3448fbc5 /audio
parent8efc4b7e2440ba2a2c19f8c056fbcb2f47d0dfbc (diff)
downloadmpv-2308eda2b8de54003372feb9d3c3a424d97621e7.tar.bz2
mpv-2308eda2b8de54003372feb9d3c3a424d97621e7.tar.xz
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.
Diffstat (limited to 'audio')
-rw-r--r--audio/out/ao_oss.c15
1 files changed, 10 insertions, 5 deletions
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;