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

ao: not start AO when receiving EOF data. #13243

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

rb-union
Copy link

@rb-union rb-union commented Jan 7, 2024

When mpv resumes audio from underrun state, if the first audio data contains EOF. mpv may get stuck in an infinite loop. ao->buffer_state->playing is true and does not change anymore, repeat blocked, waiting for old audio to play on the function fill_audio_out_buffers().
Pulse Audio continues to request data and calls stream_request_cb(). pa_stream_writable_size() continues to increase. mpv hangs and cannot play video, until Failed to allocate buffer.

buffer.c: To resolve this issue, not start AO when receiving EOF data.

Fixes: #13242

Read this before you submit this pull request:
https://github.com/mpv-player/mpv/blob/master/DOCS/contribute.md

Reading this link and following the rules will get your pull request reviewed
and merged faster. Nobody wants lazy pull requests.

When mpv resumes audio from underrun state, if the first audio
data contains EOF. mpv may get stuck in an infinite loop.
`ao->buffer_state->playing` is true and does not change anymore,
repeat `blocked, waiting for old audio to play` on the function
fill_audio_out_buffers().
Pulse Audio continues to request data and calls stream_request_cb().
pa_stream_writable_size() continues to increase. mpv hangs and
cannot play video, until `Failed to allocate buffer`.

buffer.c: To resolve this issue, not start AO when receiving
EOF data.

Fixes: mpv-player#13242
p->streaming = true;
state.playing = true;
if (got_eof) {
MP_WARN(ao, "Error starting AO with EOF data.\n");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure this makes sense.
Where exactly is the error in this case? Since the user is informed, what can he do to resolve it?

ao->driver->start(ao);
p->streaming = true;
state.playing = true;
}
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thinking about this further you can see that this code only runs if there are samples to play.
But if the AO is not started then the samples would be lost.

What I think might be broken is the logic that calls ao_drain or ao_reset when appropriate. (In your log it seems it is never called.)

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

Successfully merging this pull request may close these issues.

ao/pulse may hang when playing videos
2 participants