Skip to content

ao/pulse: fix ao_drain hang when underrun makes buf_diff negative#17652

Open
dengzhongyuan365-dev wants to merge 1 commit intompv-player:masterfrom
dengzhongyuan365-dev:master
Open

ao/pulse: fix ao_drain hang when underrun makes buf_diff negative#17652
dengzhongyuan365-dev wants to merge 1 commit intompv-player:masterfrom
dengzhongyuan365-dev:master

Conversation

@dengzhongyuan365-dev
Copy link
Copy Markdown

@dengzhongyuan365-dev dengzhongyuan365-dev commented Mar 26, 2026

With prebuf=0, on underrun read_index overtakes write_index, making
buf_diff negative. Passing it to pa_bytes_to_usec() (uint64_t) overflows
and causes ao_drain() to hang forever via an infinite mp_cond_timedwait().

Fixes: 17651

With prebuf=0, on underrun read_index overtakes write_index, making
buf_diff negative. Passing it to pa_bytes_to_usec() (uint64_t) overflows
and causes ao_drain() to hang forever via an infinite mp_cond_timedwait().

Fixes: 17651
@dengzhongyuan365-dev
Copy link
Copy Markdown
Author

@Dudemanguy
Thank you for your review. I have revised it according to your suggestions.

@Dudemanguy
Copy link
Copy Markdown
Member

Do you have an easy way to reproduce this problem?

@dengzhongyuan365-dev
Copy link
Copy Markdown
Author

dengzhongyuan365-dev commented Mar 31, 2026

Do you have an easy way to reproduce this problem?
@Dudemanguy
On low-performance machines, it's easier to reproduce a video that's played in a single loop for an extended period, typically 4-10 seconds. Otherwise, it usually takes 10 hours or even a day.

But,the code logic also presents computational problems. If an overflow occurs, it can cause subsequent stuttering, ultimately leading to the mpv freezing.

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.

2 participants