Closed Dudemanguy closed 1 month ago
Download the artifacts for this pull request:
I'd say it is still not correct. It is necessary to track the playback speed of samples when they are enqueued. See my argument in https://github.com/mpv-player/mpv/pull/11955#issuecomment-2024317171
It is necessary to track the playback speed of samples when they are enqueued. See my argument in
I don't disagree with you, but this is not trying to solve that.
It is necessary to track the playback speed of samples when they are enqueued. See my argument in
I don't disagree with you, but this is not trying to solve that.
I'm wondering why not to correct the implementation of calculating playing audio pts instead of patching the handling here.
Adjusting for AO delay is not really relevant to users and can lead to unexpected results. The newly named adjusted_audio_pts function has the speed adjustment logic folded back into it in light of this.
I don't agree with it. I think these "weird behaviors" are caused by the incorrectness of playing audio pts. If we have a correct calculation of playing audio pts there won't be negative numbers. BTW the introducing of adjusted_audio_pts will change the original semantics.
I'm actually working on a refactoring of playing audio pts calculation by using a FIFO list to track audio data enqueuing. (It is not finished yet, though.)
I'm wondering why not to correct the implementation of calculating playing audio pts instead of patching the handling here.
My interpretation is that using playing audio pts (or adjusted audio pts as I renamed it here) instead of written audio pts in various places is fundamentally not correct. Whether or not the calculation is correct is separate matter.
If we have a correct calculation of playing audio pts there won't be negative numbers.
How so? If the AO delay is greater than the last audio pts, you'll get a negative number. Is that wrong?
How so? If the AO delay is greater than the last audio pts, you'll get a negative number. Is that wrong?
Yep, that's my option: using AO delay to calculate playing audio pts is incorrect. Instead, we need to track what audio frame is actually playing by the ao driver. If no audio frame is played, the playing audio pts should be zero instead of negative values.
My interpretation is that using playing audio pts (or adjusted audio pts as I renamed it here) instead of written audio pts in various places is fundamentally not correct. Whether or not the calculation is correct is separate matter.
Why? e.g. shouldn't the progress bar be aligned to the audio pts that is actually playing, instead of the audio pts that is just written?
Much of the current sync code is written with the expectation of expectation of negative values though. We've tried some naive clamping attempts before in the past with not so great results. Of course if your change handles this and fixes this, that's great. But it might not be easy. In any case, I don't see a conflict. We can improve the current scheme. It's a relatively simple, low risk change (not necessarily in the exact current form but something similar). If someone comes up with something later that makes this obsolete, no biggie.
e.g. shouldn't the progress bar be aligned to the audio pts that is actually playing
Not really because that would include negative numbers. Whatever a user gets as a property should have at least some cosmetics to it.
Not really because that would include negative numbers. Whatever a user gets as a property should have at least some cosmetics to it.
e.g. ao_foundation
has a delay of more than 1 second:
What's more, there can be considerable delay using ao_pulse
and ao_pipewire
if connected to a remote device.
I don't think it is acceptable to users if there will be a difference of a few seconds between the progress bar and the actual pts.
I've changed the approach so that get_playback_time
is always nonnegative except for the MP_NOPTS_VALUE
case. It seems like that was the intent when it was originally added in a73415584c9dbf920ec14d26d0b0629cae81b3d5. For audio-pts
, that property can still return weird numbers but I clarified a bit in the documentation how it is different than time-pos
.
LGTM now :heart:
@Dudemanguy, after this change, time-pos
and playback-time
have exactly same code. Should we update the doc because currently doc for playback-time
still implies they are different.
Oh yeah, I missed that playback-time
is exactly the same now. Maybe we should just deprecate playback-time
. Most scripts in the wild I see use time-pos
.
Thanks. Also, it'd nice if the last "time-pos" in that audio-pts
doc be backticked like time-pos
.
See commit message for full details. Supersedes #14205. Hopefully if I understood it right, this should fix all the weird behavior that happens because the audio pts becomes negative.
This fully fixes https://github.com/mpv-player/mpv/issues/10346, and https://github.com/mpv-player/mpv/issues/12247 is still fixed (used a different file that I confirmed exhibited the described issue before some related commits closed it).