1
0
mirror of https://github.com/mpv-player/mpv synced 2025-01-30 19:52:14 +00:00

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.
This commit is contained in:
wm4 2014-09-26 15:46:39 +02:00
parent da1918b894
commit 387d5f55e6

View File

@ -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;
}