af_lavfi: add libavfilter bridge

Mostly copied from vf_lavfi. The parts that could be shared are minor,
because most code is about setting up audio and video, which are too
different.

This won't work with Libav. I used ffplay.c as guide, and noticed too
late that their setup methods are incompatible with Libav's. Trying to
make it work with both would be too much effort. The configure test for
av_opt_set_int_list() should disable af_lavfi gracefully when compiling
with Libav.

Due to option parser chaos, you currently can't have a "," as part of
the filter graph string - not even with quoting or escaping. This will
probably be fixed later.

The audio filter chain is not PTS aware. So we have to do some hacks
to make up a fake PTS, and we have to map the output PTS back to the
filter chain's method of tracking PTS changes and buffering, by
adjusting af->delay.
macosx_application: implement "Quit & remember position"

Add a menu item to quit and save the current playback position using the code
added with commit ce9a854.

Fixes #85
cocoa_common: authohide menu/dock in fullscreen

This simple fix makes it possible to access the MainManu and Dock when in
fullscreen when not using `--native-fs`.
ao_alsa: always unset ALSA error handler, cleanup on init error

The ALSA device was not closed when initialization failed.

The ALSA error handler (set with snd_lib_error_set_handler()) was not
unset when closing ao_alsa. If this is not done, the handler will still
be called when other libraries using ALSA cause errors, even though
ao_alsa was long closed. Since these messages were prefixed with
"[AO_ALSA]", they were misleading and implying ao_alsa was still used.

For some reason, our error handler is still called even after doing
snd_lib_error_set_handler(NULL), which should be impossible. Checking
with the debuggers, inserting printf(), as well as the alsa-lib source
code all suggest our error handler should not be called, but it still
happens. It's a complete mystery.
vf_lavfi: allow setting avopts
video/out: introduce vo_control for gl_common based VOs

Instead of having separate callbacks for each backend-handled feature
(like MPGLContext.fullscreen, MPGLContext.border, etc.), pass the
VOCTRL responsible for this directly to the backend. This allows
removing a bunch of callbacks, that currently must be set even for
optional/lesser features (like VOCTRL_BORDER).

This requires changes to all VOs using gl_common, as well as all
backends that support gl_common.

Also introduce VOCTRL_CHECK_EVENTS. vo.check_events is now optional.
VO backends can use VOCTRL_CHECK_EVENTS instead to implementing
check_events. This has the advantage that the event handling code in
VOs doesn't have to be duplicated if vo_control() is used.
x11: use vo_x11_control() for all VOs
w32: use vo_w32_control() for all VOs
vo: remove vo.check_events callback

Use VOCTRL_CHECK_EVENTS instead. Change the remaining VOs to use it.
Only vo_sdl and vo_caca actually need this, and vo_null, vo_lavc, and
vo_image had stubs only.
core: do mouse cursor hiding business in frontend

Do this so that not every VO backend has to setup a timer for cursor
hiding and interpret the --cursor-autohide option.
x11: remove cursor hiding logic, use VOCTRL_SET_CURSOR_VISIBILITY
vo_sdl: use VOCTRL_SET_CURSOR_VISIBILITY
w32: use VOCTRL_SET_CURSOR_VISIBILITY

This didn't even implement --cursor-autohide. Now it does, and the
behavior of the VOs under Windows change accordingly.
cocoa_common: implement mouse movement notifications

Notify the core of mouse movement events. The coordinates are converted to a
coordinate system with the origin in upper left corner, since Cocoa has it in
the lower left corner.
cocoa_common: implement VOCTRL_SET_CURSOR_VISIBILITY

Pass along cursor visibility hints to be more consistent with OSX's behaviour.
wayland: introduce vo_wayland_config

This removes the need for exposing vo_wayland_fullscreen and other functions
also this will be usefull for other vos in the future.
wayland: use VOCTRL_SET_CURSOR_VISIBILITY
cocoa_common: send mouse moved events to core when dragging

This change fixes mouse autohide when dragging mouse.
timer: refactor, add 64 bit timer function

Make OS specific timer code export a mp_raw_time_us() function, and
add generic implementations of GetTimer()/GetTimerMS() using this
function. New mpv code is supposed to call mp_time_us() in situations
where precision is absolutely needed, or mp_time_s() otherwise.

Make it so that mp_time_us() will return a value near program start.
We don't set it to 0 though to avoid confusion with relative vs.
absolute time. Instead, pick an arbitrary offset.

Move the test program in timer-darwin.c to timer.c, and modify it to
work with the generic timer functions.
timer: use gettimeofday() on Windows

MinGW-w64 emulates this via GetSystemTimeAsFileTime(), which has
supposedly the best and most stable timer source out of most others.

http://mingw-w64.svn.sourceforge.net/viewvc/mingw-w64/trunk/mingw-w64-crt/misc/gettimeofday.c