mirror of
https://github.com/mpv-player/mpv.git
synced 2026-10-24 12:10:18 +08:00
The retry path in wasapi_thread_init() used MP_TIME_US_TO_NS, giving a total budget of ~15 us before MP_FATAL killed the audio thread. The resulting log line "Retrying in 1000 ns" makes the unit confusion obvious. In practice AUDCLNT_E_DEVICE_INVALIDATED is most often hit right after the system resumes from sleep, or when the default endpoint changes, where the audio endpoint typically needs hundreds of milliseconds to come back. The current budget never covers that window, so the first playback after wake-up permanently fell back to "no audio" until the user manually restarted playback. Switch the retry schedule to milliseconds: start at 1 ms (~one Windows timer tick, effectively an immediate yield), multiply by 10 each iteration, and cap at 1 s -- i.e. 1/10/100/1000 ms, 4 retries, ~1.1 s total. Use MP_TIME_NS_TO_MS for the warning so the unit in the log matches reality.