From 6de25997a1c5eca4892ebdce492105d04feb436b Mon Sep 17 00:00:00 2001 From: wm4 Date: Thu, 8 Oct 2020 00:36:41 +0200 Subject: player: fix another nightmarish corner case Pretty much fuck this shit. --- player/audio.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'player') diff --git a/player/audio.c b/player/audio.c index f4175bc901..50c0faaf09 100644 --- a/player/audio.c +++ b/player/audio.c @@ -620,6 +620,17 @@ static void ao_process(struct mp_filter *f) // This will eventually lead to the creation of the AO + queue, due // to how f_output_chain and AO management works. mp_pin_out_request_data(f->ppins[0]); + // Check for EOF with no data case, which is a mess because everything + // hates us. + struct mp_frame frame = mp_pin_out_read(f->ppins[0]); + if (frame.type == MP_FRAME_EOF) { + MP_VERBOSE(mpctx, "got EOF with no data before it\n"); + ao_c->out_eof = true; + mpctx->audio_status = STATUS_DRAINING; + mp_wakeup_core(mpctx); + } else if (frame.type) { + mp_pin_out_unread(f->ppins[0], frame); + } return; } @@ -918,11 +929,11 @@ void fill_audio_out_buffers(struct MPContext *mpctx) mp_wakeup_core(mpctx); } - if (ao_c->ao && mpctx->audio_status == STATUS_DRAINING) { + if (mpctx->audio_status == STATUS_DRAINING) { // Wait until the AO has played all queued data. In the gapless case, // we trigger EOF immediately, and let it play asynchronously. - if (!ao_is_playing(ao_c->ao) || - (opts->gapless_audio && !ao_untimed(ao_c->ao))) + if (!ao_c->ao || (!ao_is_playing(ao_c->ao) || + (opts->gapless_audio && !ao_untimed(ao_c->ao)))) { MP_VERBOSE(mpctx, "audio EOF reached\n"); mpctx->audio_status = STATUS_EOF; -- cgit v1.2.3