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

[osx] - fix issues with turning off/on tv when playback is paused #4441

Merged
merged 3 commits into from
Mar 22, 2014

Conversation

Memphiz
Copy link
Member

@Memphiz Memphiz commented Mar 18, 2014

This fixes issues which users pointed out when turning off the amp or tv over night and try to continue where left of on the next day.

This change does the following

  1. In ActiveAE there was a race condition when lostdevice (from windowing) occured with devicechanged callbacks (something like that i think :) ).
  2. When we open the default device in the osx sink we need to query the device from CoreAudio instead of using our maybe outdated deviceid in the deviceslist (this is needed because in some constellations we only get windowing callbacks - but not devicechange callbacks rom osx).
  3. The windowing code that fires OnDeviceLost and OnDeviceReset callbacks had a flawed logic. Now that those callbacks are used by ActiveAE those issues resulted in AE-Sleep-Of-Death - this needed a tiny refactor and fix

The last one looks a bit ugly in the diff but it is really easy what it does:
a. Adds a timer which is started whenever osx tells us "lost device"
aa. that timer is canceled when we get a proper "device reset" callback from osx
ab. if this is not the case the timeout of this timer will fire that callback (after 3secs with lost device) - and so wakes up AE again.
b. The callbacks we fire are refactored into 2 methods which are dumb (not checking flags or anything)
c. The logic of when those callbacks are called is completely in the "DisplayReconfigured" method
d. In addition to the kCGDisplayBeginConfigurationFlag and kCGDisplaySetModeFlag flags we also fire the onresetdevice callback when flags == 0. This is something which is not documented in Apples API but it is definitly happening (verified with a user)
e. Before this we only fired onresetdevice when there was a valid screen given in the callback from the os. But this assumption is not true. Because when the tv is turned off osx calls us without valid screen. In that case we still need to fire the onresetdevice for AE - else the engine never wakes up again.

Lot of text - hopefully it helps in understanding what this does - and that it is really needed for gotham :)

The bug hunting can be followed here:

http://forum.xbmc.org/showthread.php?tid=185395

Thx to repstein and gigantur who really did a great job in providing logs with a dozens of testbuilds over the last weeks for tracking the issue down (and having a response time which was only a couple of hours each time!).

Also thx to @FernetMenta who did a great job in interpreting that log files and finding the race and its fix.

FernetMenta and others added 3 commits March 18, 2014 21:15
…enever a

lostdevice callback was called before. Do this by adding a timer (similar like done on x11). Also
handle "flags == 0" as devicereset (on some strange constellations we are
called with flags 0 instead of proper flags - this is undocumented but
it happens...).
@Memphiz Memphiz added the Gotham label Mar 18, 2014
@t-nelson
Copy link
Contributor

@Memphiz Can you ping whoever needs to review this please?

jenkins build this please

@Memphiz
Copy link
Member Author

Memphiz commented Mar 21, 2014

@jmarshallnz and @davilla

1 similar comment
@Memphiz
Copy link
Member Author

Memphiz commented Mar 21, 2014

@jmarshallnz and @davilla

@davilla
Copy link
Contributor

davilla commented Mar 22, 2014

ok

@t-nelson
Copy link
Contributor

@jmarshallnz's button

jmarshallnz added a commit that referenced this pull request Mar 22, 2014
[osx] - fix issues with turning off/on tv when playback is paused
@jmarshallnz jmarshallnz merged commit 0cfc102 into xbmc:master Mar 22, 2014
jmarshallnz added a commit that referenced this pull request Mar 24, 2014
[osx] - fix issues with turning off/on tv when playback is paused
@t-nelson t-nelson removed the Gotham label Mar 24, 2014
@MartijnKaijser MartijnKaijser modified the milestones: Helix 14.0-alpha1, Gotham13.0-rc1 May 21, 2014
@Memphiz Memphiz deleted the osxdevicereset branch May 22, 2016 12:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants