Repository navigation
Conversation
when the output device changes we get a handleRestart notification, this calls stop() followed by start(). in the case of playback being paused, start() unpauses the synchronizer and starts requesting media data. when paused we don't get any data, the renderer stays ready for more media data and feed() is called in a busy loop, using 100% of a core. furthermore, since the notification runs on a different thread than the playback thread, we can possibly have race conditions between start, stop and pausing. fix this by tracking the paused state, not calling start unconditionally in the restart handler and properly handle requesting media data in set_pause. also run start, stop and pause on the same queue as feed, so calls can not interleave and prevent any race condition.
Contributor
|
Passed my test. I pulled the latest master and then applied the patch in this PR. I built mpv with TSan enabled. I then ran the same test as described in this comment on the other PR. When I connected my AirPods Max mpv detected the hotplug event and correctly switched the audio output device: CPU monitoring only showed an increase from No errors were reported by TSan. A side note, in order to adhere to the following best practice recommended in Apple's Energy Efficiency Guide for Mac Apps
When playback is paused for more than 6 seconds IINA stops the CVDisplayLink in order to go completely idle: |
6 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
alternative to #18390
verified all problems mentioned on #18390 and fixed it slightly differently. couldn't verify some of the claims and deemed those fixes unnecessary, like the handler/notification thread. changes were inspired by the other PR, but adjusted and cleaned up.
@low-batt if you have time, could you pls test this again?