summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-09-26 15:46:39 +0200
committerwm4 <wm4@nowhere>2014-09-26 15:46:39 +0200
commit387d5f55e639425bfb6ee1efec4e21202e5642ad (patch)
treef0bd1b62dfa10029d31a33c7169bc7bc9f5f714b
parentda1918b89451905255e2ad05790c944615e2a51c (diff)
downloadmpv-387d5f55e639425bfb6ee1efec4e21202e5642ad.tar.bz2
mpv-387d5f55e639425bfb6ee1efec4e21202e5642ad.tar.xz
ao_sndio: print a warning when draining audio
libsndio has absolutely no mechanism to discard already written audio (other than SIGKILLing the sound server). sio_stop() will always block until all audio is played. This is a legitimate design bug. In theory, we could just not stop it at all, so if the player is e.g. paused, the remaining audio would be played. When resuming, we would have to do something to ensure get_delay() returns the right value. But I couldn't get it to work in all cases.
-rw-r--r--audio/out/ao_sndio.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/audio/out/ao_sndio.c b/audio/out/ao_sndio.c
index 5777aa4aac..6afe0f9eaf 100644
--- a/audio/out/ao_sndio.c
+++ b/audio/out/ao_sndio.c
@@ -33,6 +33,7 @@ struct priv {
struct sio_hdl *hdl;
struct sio_par par;
int delay;
+ bool playing;
int vol;
int havevol;
#define SILENCE_NMAX 0x1000
@@ -224,11 +225,17 @@ static void reset(struct ao *ao)
{
struct priv *p = ao->priv;
- if (!sio_stop(p->hdl))
- MP_ERR(ao, "reset: couldn't stop\n");
- p->delay = 0;
- if (!sio_start(p->hdl))
- MP_ERR(ao, "reset: couldn't start\n");
+ if (p->playing) {
+ MP_WARN(ao, "Blocking until remaining audio is played... (sndio design bug).\n");
+
+ p->playing = false;
+
+ if (!sio_stop(p->hdl))
+ MP_ERR(ao, "reset: couldn't stop\n");
+ p->delay = 0;
+ if (!sio_start(p->hdl))
+ MP_ERR(ao, "reset: couldn't start\n");
+ }
}
/*
@@ -241,8 +248,8 @@ static int play(struct ao *ao, void **data, int samples, int flags)
n = sio_write(p->hdl, data[0], samples * ao->sstride) / ao->sstride;
p->delay += n;
- if (flags & AOPLAY_FINAL_CHUNK)
- reset(ao);
+ p->playing = true;
+ /* on AOPLAY_FINAL_CHUNK, just let it underrun */
return n;
}