mirror of
https://github.com/mpv-player/mpv
synced 2024-09-09 01:16:56 +02:00
core: fix EOF handling with untimed audio outputs
When using an audio output without a native playback rate (such as ao_pcm), the code plays audio further when the current write position is behind video. After support for continuing audio after the end of video was added, this could cause a deadlock: audio was not played further, but neither was EOF triggered. Fix the code to properly handle playback of remaining audio after video ends in the untimed audio case (audio-only case was not affected, only the case where a video stream exists but ends before the audio stream).
This commit is contained in:
parent
1e90a8657d
commit
f9beb08a61
26
mplayer.c
26
mplayer.c
@ -2529,9 +2529,6 @@ static int fill_audio_out_buffers(struct MPContext *mpctx, double endpts)
|
|||||||
|
|
||||||
current_module = "play_audio";
|
current_module = "play_audio";
|
||||||
|
|
||||||
if (ao->untimed && mpctx->sh_video && mpctx->delay > 0)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
// hack used by some mpeg-writing AOs
|
// hack used by some mpeg-writing AOs
|
||||||
ao->brokenpts = ((mpctx->sh_video ? mpctx->sh_video->timer : 0) +
|
ao->brokenpts = ((mpctx->sh_video ? mpctx->sh_video->timer : 0) +
|
||||||
mpctx->delay) * 90000.0;
|
mpctx->delay) * 90000.0;
|
||||||
@ -3453,9 +3450,9 @@ static void run_playloop(struct MPContext *mpctx)
|
|||||||
pause_player(mpctx);
|
pause_player(mpctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mpctx->sh_audio && !mpctx->restart_playback) {
|
if (mpctx->sh_audio && !mpctx->restart_playback && !mpctx->ao->untimed) {
|
||||||
int status = fill_audio_out_buffers(mpctx, endpts);
|
int status = fill_audio_out_buffers(mpctx, endpts);
|
||||||
full_audio_buffers = status >= 0 && !mpctx->ao->untimed;
|
full_audio_buffers = status >= 0;
|
||||||
// Not at audio stream EOF yet
|
// Not at audio stream EOF yet
|
||||||
audio_left = status > -2;
|
audio_left = status > -2;
|
||||||
}
|
}
|
||||||
@ -3667,15 +3664,16 @@ static void run_playloop(struct MPContext *mpctx)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (mpctx->restart_playback && !video_left) {
|
if (mpctx->sh_audio && (mpctx->restart_playback ? !video_left :
|
||||||
if (mpctx->sh_audio) {
|
mpctx->ao->untimed && (mpctx->delay <= 0 ||
|
||||||
int status = fill_audio_out_buffers(mpctx, endpts);
|
!video_left))) {
|
||||||
full_audio_buffers = status >= 0 && !mpctx->ao->untimed;
|
int status = fill_audio_out_buffers(mpctx, endpts);
|
||||||
// Not at audio stream EOF yet
|
full_audio_buffers = status >= 0 && !mpctx->ao->untimed;
|
||||||
audio_left = status > -2;
|
// Not at audio stream EOF yet
|
||||||
}
|
audio_left = status > -2;
|
||||||
mpctx->restart_playback = false;
|
|
||||||
}
|
}
|
||||||
|
if (!video_left)
|
||||||
|
mpctx->restart_playback = false;
|
||||||
if (mpctx->sh_audio && buffered_audio == -1)
|
if (mpctx->sh_audio && buffered_audio == -1)
|
||||||
buffered_audio = mpctx->paused ? 0 : ao_get_delay(mpctx->ao);
|
buffered_audio = mpctx->paused ? 0 : ao_get_delay(mpctx->ao);
|
||||||
|
|
||||||
@ -3724,7 +3722,7 @@ static void run_playloop(struct MPContext *mpctx)
|
|||||||
double audio_sleep = 9;
|
double audio_sleep = 9;
|
||||||
if (mpctx->sh_audio && !mpctx->paused) {
|
if (mpctx->sh_audio && !mpctx->paused) {
|
||||||
if (mpctx->ao->untimed) {
|
if (mpctx->ao->untimed) {
|
||||||
if (!mpctx->sh_video)
|
if (!video_left)
|
||||||
audio_sleep = 0;
|
audio_sleep = 0;
|
||||||
} else if (full_audio_buffers) {
|
} else if (full_audio_buffers) {
|
||||||
audio_sleep = buffered_audio - 0.050;
|
audio_sleep = buffered_audio - 0.050;
|
||||||
|
Loading…
Reference in New Issue
Block a user