mpv-player/mpv — pull request #1257 by kevmitch (2014-11-08 15:07:58+00:00)
Title: [WIP] Implement device notifications for wasapi 

Currently wasapi ao hangs the player when audio properties such as sample rate or effects are changed during playback. This PR implements the necessary machinery to properly handle such changes and allow playback to keep going. When the ao_wasapi feed thread is notified of a device change, it sends an ao_request_reload which shortly terminates it and starts a new one.

With a single mpv instance this has been tested to work quite well changing the "shared mode" sample rate/bit depth as well as the applied effects. I don't currently have a second sound-card set up, so I have not been able to test if it will properly reroute to a the remaining device when the one playing is disabled or disconnected, though this is *supposed* to work.

Unfortunately (and oddly), if I have two mpv instances running simultaneously and change the shared mode sample rate several times. One of the instances will hang by around the 10th change. Interestingly, it's feed thread continues to receive change notification.