ring: use a different type for read/write pointers

uint_least32_t could be larger than uint32_t, so the return values of
mp_ring_get_wpos/rpos must be adjusted. Actually just use unsigned long
as type instead, because that is less awkward than uint_least32_t.
audio/out: adjust documentation comments
audio/out/push: add mechanism for event-based waiting

Until now, we've always calculated a timeout based on a heuristic when
to refill the audio buffers. Allow AOs to do it completely event-based
by providing wait and wakeup callbacks.

This also shuffles around the heuristic used for other AOs, and there is
a minor possibility that behavior slightly changes in real-world cases.
But in general it should be much more robust now.

ao_pulse.c now makes use of event-based waiting. It already did before,
but the code for time-based waiting was also involved. This commit also
removes one awkward artifact of the PulseAudio API out of the generic
code: the callback asking for more data can be reentrant, and thus
requires a separate lock for waiting (or a recursive mutex).
input: separate wakeup pipe creation into a separate function

Error handling is slightly reduced: we assume that setting a pipe
to non-blocking can never fail.
audio/out/push: add a way to wait for the audio device with poll()

Will be used for ALSA.
ao_alsa: use poll() to wait for device

This means the audio feed thread is woken up exactly at the time new
data is needed, instead of using a time-based heuristic.
audio: change handling of an EOF corner case

This code handles buggy AOs (even if all AOs are bug-free, it's good for
robustness). Move handling of it to the AO feed thread. Now this check
doesn't require magic numbers and does exactly what's it supposed to do.
audio/out/push: handle draining correctly

This did not flush remaining audio in the buffer correctly (in case an
AO has an internal block size). So we have to make the audio feed thread
to write the remaining audio, and wait until it's done.

Checking the avoid_ao_wait variable should be enough to be sure that all
data that can be written was written to the AO driver.
tv: remove sysinfo() usage

This call was used limited the buffer size if installed RAM was below 16
MB. This stopped being useful a decade ago. The check could also
overflow on 32 bit systems. Just get rid of it.
ao_alsa: reduce spurious wakeups

Apparently this can happen. So actually only return from waiting if ALSA
excplicitly signals that new output is available, or if we are woken up
externally.
audio/out/push: keep some extra buffer

So the device buffer can be refilled quickly. Fixes dropouts in certain
cases: if all data is moved from the soft buffer to the audio device
buffer, the waiting code thinks it has to enter the mode in which it
waits for new data from the decoder. This doesn't work, because the
get_space() logic tries to keep the total buffer size down. get_space()
will return 0 (or a very low value) because the device buffer is full,
and the decoder can't refill the soft buffer. But this means if the AO
buffer runs out, the device buffer can't be refilled from the soft
buffer. I guess this mess happened because the code is trying to deal
with both AOs with proper event handling, and AOs with arbitrary
behavior.

Unfortunately this increases latency, as the total buffered audio
becomes larger. There are other ways to fix this again, but not today.

Fixes #818.
ao_alsa: make device the first sub option

This is more convenient.
gl_x11: always require some GLX API functions, avoid dlsym()

The functions glXGetProcAddressARB() and glXQueryExtensionsString() were
loaded using dlsym(). This could fail when compiling to libmpv, because
then dlopen(NULL, ...) will look in the main program's list of
libraries, and the libGL linked to libmpv is never considered. (Don't
know if this somehow could be worked around.) The result is that using
vo_opengl with libmpv can fail.

Avoid this by not using dlsym(). glXGetProcAddressARB() was already used
directly in the same file, and that never caused any problems. (Still
add it to the configure test.) glXQueryExtensionsString() is documented
as added in GLX 1.1 - that's ancient.
gl_x11: remove workaround for PPC OSX 10.4

Added in 2010 with commit 4a8486f8 (svn commit 30994). I doubt anyone
still uses X11 on OSX, and we probably don't support 10.4 either.
gl_wayland: remove probably unneeded workaround

This would imply eglGetProcAddress() doesn't work correctly, but using
dlsym() does. For now get rid of it - it won't work in libmpv, and we'll
probably need a better workaround if it's still broken.

This code was in the initial wayland commit.
gl_common: remove dlsym() fallback

See previous commits.
player: hide audio/video codec and file format messages

None of these are very important usually. For error analysis, the plain
log is useless anyway, and this information is still printed with "-v".
command: add const to mp_notify_property
command: property notification when changing af/vf
client API: report success status when running commands

Until now, an error was reported only if the command couldn't be parsed.
Attempt to do more fine-grained reporting. This is not necessarily
perfect, but it's an improvement.