audio: preallocate audio buffers on resize

This avoids too many realloc() calls if the caller is appending to an
audo buffer. This case is actually quite noticeable when using something
that buffers a large amount of audio.
encode: disable keep-open when encoding
manpage: add notes when to use/not use certain AO and VO drivers

Conflicts:
	DOCS/man/en/vo.rst
encode: don't resume playback when encoding

The previous commit doesn't handle additionally loaded config files,
such as the playback resume mechanism.
vf: add function to remove a filter from the chain
vf: remove autoinserted filters on reconfig

When using rotation with hw decoding, and the VO does not support
rotation, vf_rotate is attempted to be inserted. This will go wrong, and
after that it can't recover because a vf_scale filter was autoinserted.
Just removing all autoinserted filters before reconfig fixes this.
man: minor typo why not to use portaudio
cache: remove redundant log prefix
ao_coreaudio: add verbose output of detected channel layouts

This can be useful for debugging purposes.
ao_coreaudio: log even more info in verbose mode

This logs more info that can be used for debugging purposes, in particular
it prints all the AudioChannelDescription in the descriptions array.
demux_mkv: enable parsing for mp3

For some reason, some files appear to have broken mp3 packets, or at
least in a form that libavcodec can't deal with. The audio in the sample
file in question could not be decoded using libavcodec.

The problematic file had variable packet sizes, and the libavcodec
decoder kept printing "mp3: Header missing" for each packet it was fed.
Remuxing with mkvmerge fixes the problem. The mp3 data is probably not
VBR, and remuxing resulted in fixed-size mp3 frames. So I don't know why
the sample file was muxed this way - it might just be incorrect.

The sample file had "libmkv 0.6.4" as MuxingApp (although I could not
get mkvinfo to print this element, maybe the file uses an incorrect
element ID), and "HandBrake 0.9.4" as WritingApp.

Note that the libmpg123 decoder does not have any issues with it. It's
probably more robust, because libmpg123 was made to decode whole mp3
files, not just single frames.

Fixes issue #742.
manpage: improve --osd-level description
stream: use uninterruptible sleep on reconnecting

This is the only function which actually used the time argument of
stream_check_interrupt(). Considering that the whole player freezes
anyway, this is not worth the complication.

Also generally reduce the maximum wait time due to timeout. Introduce
exponential backoff, which makes the first reconnect retries faster, but
still waits up to 500ms in the later retries.
manpage: forced->used
manpage: fix grammar
Revert "wayland: print waylands display erros"

This reverts commit 6e34b0ec1f50612cb2767da3dbc27be0be63041d.

There has always been an error message "proxy already has a listener" and
I couldn't reproduce where it is comming from until now. The display interface
already has a listener and we can't overwrite it. Now remove the code and avoid
this error message.

Conflicts:
	video/out/wayland_common.c
osd: make code C99

This used an unnamed union, which is allowed in GNU C and C11, but not
C99. This broke the build with some older compilers.

Replaces pull request #744.
demux_mkv: enable parsing for VP9

VP9 packets can contain 2 frames in some video packets (from which 1
frame is invisible). Due to a design mismatch between libvpx and the
libavcodec vp9 decoder, libvpx can take the "full" packets, but lavc vp9
can not. The consequence is that we have to split the packets if we want
to feed them to the lavc codec.

This is not entirely correct yet: timestamp handling is missing.
--demuxer=lavf and ffmpeg native utilities have the same problem. We can
fix this only once the ffmpeg VP9 parser is fixed.
terminal: always use SA_RESTART with sigaction()

One problem is that for example stdio functions won't restart syscalls
manually, and instead treat EINTR as an error. So passing SA_RESTART is
the only sane thing to do, unless you have special requirements, which
we don't.
build: use -pthread when available

Our code currently tries to link -lpthread and adds stuff like -D_REENTRANT
based on the target platform.

GCC actually supports to just pass a -pthread compiler and linker flag that
will automatically enable threading and define the correct symbols for the
platform, so let's try to just use that as our first choice.

clang also supports -pthread but it must be used only as a compiler flag,
so we also take care of that scenario with this commit.