xbmc/xbmc — comment on commit b28f8f15c9ff7dfa4fb8783ae64f1e77d8216277
File:  line 0
By FernetMenta:

Ok, did that test:

We receive the RRScreenChangeNotify event after the change of refresh rate has occurred and the system is ready to continue. On this event windowing fires the OnResetDisplay event. The OnLostDisplay event is fired just before windowing calls xrandr internally.

Now if I call xrandr from the outside, vdpau detects a display preemption error and starts to clears down. It tries to release resources which results in some "invalid handle" errors as follow-ups to preemption. I think those do not harm.

Then we come to the interesting point:
On my test system the RRScreenChangeNotify has just arrived before vdpau started to re-initialize but I think this is not guaranteed. So:

1)
If VC_ERROR was returned in this case, vdpau would not wait for the OnResetDevice event and might start re-configuring too early

2)
If we set the display state to VDPAU_LOST in case of VDP_STATUS_DISPLAY_PREEMPTED seems to be a better solution in this case. The downside is that this error might also be a fatal error, though not very likely.

Should we add a fail safe timer to solution 2, which sets the state to error after a couple of unsuccessful attempts to recover?