w32_common: don't override alt+space

Apparently, stealing this from the WM is bad form, just like with F10.

Fixes #1254.
Revert "w32_common: don't override alt+space"

This reverts commit d859549424174179768fcd0310c75823a5ff7cb1.

Going to apply the alternative fix through PR #1256, which came just
some seconds after pushing the reverted commit. The reverted commit
was reported as not actually working.
w32_common: open window menu on Alt+Space

Since mpv doesn't call TranslateMessage, this must be done manually.

Should fix #1254
player: improve audio time display

This commit fixes a "cosmetic" user interface issue. Instead of
displaying the interpolated seek time on OSD, show the actual audio
time.

This is rather silly: when seeking in audio-only mode, it takes some
iterations until audio is "ready", but on the other hand, the audio
state machine is rather fickle, and fixing this cosmetic issue would be
intrusive. So just add a hack that paints over the ugly behavior as
perceived by the user. Probably the lesser evil.

It doesn't happen if video is enabled, because that mode sets the
current time immediately to video PTS. (Audio has to be synced to video,
so the code is a bit more complex.)

Fixes #1233.
mp_image: check memory allocation
audio: handle reinit after AO reload slightly cleaner

Don't print bogus messages about packets read in verbose mode.
audio/out: make ao_request_reload() idempotent

This is what you would expect. Before this commit, each
ao_request_reload() call would just queue a reload command, and then
recreate the AO for the number of times the function was called.

Instead of sending a command, introduce some sort of event retrieval
mechanism. At least for the reload case, use atomics, because we're too
lazy to setup an extra mutex.
video/out: minor simplification to event query function

The "clear" parameter is confusing and useless.
audio/out: consistently use double return type for get_delay

ao_get_delay() returns double, but the get_delay callback still
returned float.
atomics: add atomic_compare_exchange_strong()

As usual, we use C11 semantics, and emulate it if <stdatomic.h> is not
available.

It's a bit messy with __sync_val_compare_and_swap(). We assume it has
"strong" semantics (it can't fail sporadically), but I'm not sure if
this is really the case. On the other hand, weak semantics don't seem to
be possible, since the builtin can't distinguish between the two failure
cases that could occur. Also, to match the C11 interface, use of gcc
builtins is unavoidable. Add a check to the build system to make sure
the compiler supports them (although I don't think there's any compiler
which supports __sync_*, but not these extensions).

Needed for the following commit.
audio/out/pull: avoid deadlock if audio callback stops

If the audio callback suddenly stops, and the AO provides no "reset"
callback, then reset() could deadlock by waiting on the audio callback
forever.

The waiting was needed to enter a consistent state, where the audio
callback guarantees it won't access the ringbuffer. This in turn is
needed because mp_ring_reset() is not concurrency-safe.

This active waiting is unavoidable. But the way it was implemented, the
audio callback had to call ao_read_data() at least once when reset() is
called. Fix this by making ao_read_data() set a flag upon entering and
leaving, which basically turns p->state into some sort of spinlock.

The audio callback actually never needs to spin, because there are only
2 states: playing audio, or playing silence. This might be a bit
surprising, because usually atomic_compare_exchange_strong() requires a
retry-loop idiom for correct operation.

This commit is needed because ao_wasapi can (or will in the future)
randomly stop the audio callback in certain corner cases. Then the
player would hang forever in reset().
command: send property-change event on playlist change
audio: use AVBufferRef to allocate audio frames

A first step towards refcounted audio frames.

Amazingly, the API just does what we want, and the code becomes
simpler. We will need to NIH allocation from a pool, though.
dvd, bluray: reload demuxer on title changes

Causes the player to reload the demuxer and to relist the found
streams. Probably slightly dangerous/broken, because the demuxer
thread and possibly even the decoders will keep reading data from
the new title before the new demuxer takes over.

Fixes #1250.
player: don't try to use duration 0
audio: add mp_audio_pool

A helper to allocate refcounted audio frames from a pool. This will
replace the static buffer many audio filters use (af->data), because
such static buffers are incompatible with refcounting.
audio: add function to convert AVFrame to mp_audio references

This is somewhat duplicated from ad_lavc.c and af_lavfi.c, but will
eventually be used by both.
af_format: remove redundant message prefixes
audio: change how filters are inserted on playback speed changes

Use a pseudo-filter when changing speed with resampling, instead of
somehow changing a samplerate somewhere. This uses the same underlying
mechanism, but is a bit more structured and cleaner. It also makes some
of the following changes easier.

Since we now always use filters to change audio speed, move most of the
work set_playback_speed() does to recreate_audio_filters().
audio: clear buffer array too with mp_audio_set_null_data()