mpv-player / mpv

🎥 Command line video player
https://mpv.io
Other
28.37k stars 2.91k forks source link

Audio stuttering on macOS since v0.37.0 #13880

Closed NextFire closed 6 months ago

NextFire commented 6 months ago

Possibly related issues/PRs: https://github.com/mpv-player/mpv/issues/13676 https://github.com/mpv-player/mpv/pull/12643#issuecomment-1774264729 https://github.com/mpv-player/mpv/issues/13348

Important Information

Provide following Information:

Reproduction steps

mpv <any file> --no-config

Expected behavior

No audio stuttering.

Actual behavior

Audio stutters every 20 to 60 seconds when playing any file.

I also get these kinds of errors in the macOS console:

Log file

mpv.log

(There were stutters at 0:30 and 0:40 but nothing relevant was logged)

Sample files

N/A

NextFire commented 6 months ago

Sorry for the confusion, I believe 0.37 introduced the bug as I downgraded to 0.36 and am no more able reproduce the issue

m154k1 commented 6 months ago

Can you try reverting https://github.com/mpv-player/mpv/commit/36d5b5261282dd964f80cd2bb04bb53a7c6d895b and see if that helps?

NextFire commented 6 months ago

I can confirm reverting this commit resolved the issue

Dudemanguy commented 6 months ago

Probably worth reverting before the next release. I think there are various reports of audio issues that caused on macOS. cc @Akemi.

Akemi commented 6 months ago

i suppose we could do that. what was the reasoning behind using/introducing ao_read_data_nonblocking?

kasper93 commented 6 months ago

It was introduced to avoid locking audio thread. /CC @t-8ch

m154k1 commented 6 months ago

Note: ao_read_data_nonblocking works fine for avfoundation ao. Maybe this can help: https://github.com/mpv-player/mpv/blob/ab504514b874c66fa83dd17cafd4092220138a2b/audio/out/ao_avfoundation.m#L79-L84

kasper93 commented 6 months ago

huh, just use ao_read_data at this point...

Akemi commented 6 months ago

It was introduced to avoid locking audio thread. /CC @t-8ch

so it should possibly be reinvestigated in the future?

t-8ch commented 6 months ago

The nonblocking variant was introduced specifically for ao_pipewire as it uses a realtime audio thread, which should not be blocked.

I extended the usage to other AOs that are capable of reporting the actually available number of samples to the audio server.

If it does not work work for those other AOs should be fine to revert it.

t-8ch commented 6 months ago

I would be interested however why there is only one report so far. (There was also one similar report for ao_pipewire)

It only seems to happen for very few people.

NextFire commented 6 months ago

Thank you!