Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

audio: fix lack of reinitialization on format change with pull AOs #10569

Merged
merged 2 commits into from
Aug 23, 2022

Conversation

philipl
Copy link
Member

@philipl philipl commented Aug 23, 2022

We have previously had a problem where pull AOs (such as pipewire)
would not reinitialize on a format change when going between two
audio-only files. In such a situation, playback would stop after the
first file.

We initially attempted to fix this by explicitly draining on EOF, which
solves that problem but introduces a blocking step where we don't
actually want one, breaking gapless audio, and causing dropped frames
at the end of playback for files with video in them too.

uau did some investigation and noticed that we do not send a wakeup
event when we encounter end-of-stream in ao_read_data(), in contrast to
the equivalent logic for push AOs in ao_play_data().

Inserting that wakeup fixes the original problem as well as avoiding
the new problems mentioned above.

Fixes #10566

@sfan5
Copy link
Member

sfan5 commented Aug 23, 2022

The revert should probably be a separate commit.

@philipl
Copy link
Member Author

philipl commented Aug 23, 2022

Split into two commits.

We have previously had a problem where pull AOs (such as pipewire)
would not reinitialize on a format change when going between two
audio-only files. In such a situation, playback would stop after the
first file.

We initially attempted to fix this by explicitly draining on EOF, which
solves that problem but introduces a blocking step where we don't
actually want one, breaking gapless audio, and causing dropped frames
at the end of playback for files with video in them too.

So, let's undo these changes and do something better in the next
commit.
uau did some investigation and noticed that we do not send a wakeup
event when we encounter end-of-stream in ao_read_data(), in contrast to
the equivalent logic for push AOs in ao_play_data().

Inserting that wakeup fixes the original problem of lack of
reinitialization on a format change without the problems we saw with
the previous attempted fix.

Fixes mpv-player#10566
@philipl philipl merged commit ed77172 into mpv-player:master Aug 23, 2022
@t-8ch
Copy link
Contributor

t-8ch commented Aug 23, 2022

Thanks for fixing this properly and sorry for breaking it -.-

@philipl philipl deleted the fix-ao-wakeup branch August 23, 2022 21:54
@philipl
Copy link
Member Author

philipl commented Aug 23, 2022

@t-8ch No worries. I was the one who tested it and didn't detect the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

mpv drop frames in the end of all videos when draining AO
3 participants