ao/wasapi: fix leaked deviceID
ao/wasapi: reenable the reset function

the race condition that necessitated disabling
this was fixed in
e4403523131a69a92a8418bb3714090a408680c7
ao/wasapi: make calling of thread_init consistent with thread_uninit
ao/wasapi: improve error messages and add more debug statements

also enforce more consistency in the exit codes and error handling

thanks to Jonathan Yong <10walls@gmail.com>
ao/wasapi: tidy up better on failure

Before, failures, particularly in the thread loop init, could lead to a
bad state for the duration of mpvs execution. Make sure that
everything that was initialized gets properly and safely
uninitialized.
ao/wasapi: fix possible null dereference of pDevice

IMMDeviceEnumerator::GetDefaultAudioEndpoint may set pDevice to null on failure.

http://msdn.microsoft.com/en-us/library/windows/desktop/dd371401%28v=vs.85%29.aspx
ao/wasapi: put loading of default device in it's own function
ao/wasapi: look for "multimedia" default device instead of "console"

console is more for system notifications / voice command, mpv is most certainly multimedia

http://msdn.microsoft.com/en-us/library/windows/desktop/dd370842%28v=vs.85%29.aspx
ao/wasapi: new wasapi device monitoring interface

Implement skeleton IMMNotificationClient to watch for changes in the
sound device.  This will make recovery possible from changes shared
mode sample rate, bit depth, "enhancements"/effects and even graceful
device removal.

http://msdn.microsoft.com/en-us/library/windows/desktop/dd371417%28v=vs.85%29.aspx

Signed-off-by: Kevin Mitchell <kevmitch@gmail.com>
ao/wasapi: add convenience functions for change notifiy
ao/wasapi: request reset on appropriate events

on changes to PKEY_AudioEngine_DeviceFormat, device status, and default device.
call ao_reload directly in the change_notify "methods".

this requires keeping a device enumerator around for the duration of
execution, rather than just for initially querying devices
ao/wasapi: add retry loop on AUDCLNT_E_DEVICE_IN_USE

this works around reinitializing too fast on device property changes
ao/wasapi: request ao reload on thread_feed failures

Even with change notifications, there are still (rare) cases when the
feed thread gets AUDCLIENT_DEVICE_INVALIDATED. So handle failures in
thread_feed by requesting ao_reload.
Merge branch 'wasapi_fix2'
audio/out: switch back to wasapi as default on win32

dsound was set as default, because there were some hard to fix problems
with wasapi. These problems were probably fixed now, so let's try with
wasapi as default again.
ao_alsa: check for EAGAIN too

Simply retry on EAGAIN.

I've seen this in several other projects; it might be just cargo-culting
though.
command: playlist property: return if an entry is currently playing

This actually doesn't even write/return the new sub-property, because
I dislike the idea of dumping that field for every single playlist
entry, even though it's "needed" only for one.

Fixes #1260.
command: adjust previous commit

Due to the current code structure, the "current" entry and the entry
which is playing can be different. This is probably silly, but still
try to mark the entries correctly.

Refs #1260.
build: check for mingw-w64 explicitly

And fail building if not any of MingW-w64 or POSIX are found. Obviously,
mpv needs one of those 2.
wscript: move down some less important checks