mplayer: don't disable term-osd with -v

I don't see any reason for doing this.
mplayer: move DVB channel skip code

Try not to cause unnecessary special cases.
mplayer: keep volume persistent, even when using --volume

Consider:

    mpv --volume 10 file1.mkv file2.mkv

Before this commit, the volume was reset to 10 when playing file2.mkv.
This was inconsistent to most other options. E.g. --brightness is a
rather similar case.

In general, settings should never be reset when playing the next file,
unless the option was explicitly marked file-local. This commit
corrects the behavior of the --volume and --mute options.

File local --volume still works as expected:

    mpv --{ --volume 10 file1.mkv file2.mkv --}

This sets the volume always to 10 on playback start.

Move the m_config_leave_file_local() call down so that the mixer code
in uninit_player() can set the option volume and mute variables without
overwriting the global option values.

Another subtle issue is that we don't want to set volume if there's no
need to, which is why the user_set_volume/mute fields are introduced.
This is important because setting the volume might change the system
volume depending on other options.
core: add --reset-on-next-file option

This option can be used to selectively reset settings when playing the
next file in the playlist (i.e. restore mplayer and mplayer2 behavior).

Might remove this option again should it turn out that nobody uses it.
mplayer: remove unnecessary variable
ao_jack: fix deprecation warning

jack_port_get_total_latency is deprecated: use the "new" API based on
jack_port_get_latency_range instead.
command: fix deref before NULL check

Was accidentally broken in the last global variable removal round.
core: remove dead --vsync leftovers
demux: always sort chapters

The condition that checked whether the chapters are out of order and
should be sorted was inverted. This likely wasn't noticed in testing,
because even if the chapters are unsorted, if the last two chapters
were sorted, the rest got sorted too.

Instead of doing this silly check, always sort the chapters after
demuxer initialization. Also make sure the sort order is stable in case
chapter start times are the same (original_index check).
demux: simplify chapter appending code

This pre-allocation looked tricky and awkward. Use MP_TARRAY_APPEND(),
which makes the code simpler. This even keeps the pre-allocation.
osd_libass: actually free ASS_Tracks

Not a real leak, just for getting clean valgrind reports on exit.
audio/decode: remove vararg from ad_control()

This was unused and dumb. Ancient MPlayer used varargs instead of void*
arguments for control() functions, and this was the last leftover.
ad_lavc: use fmt-conversion to map sample formats
af: uncrustify
audio/filter: replace pointless memcpys with assignments

The change in af_scaletempo actually fixes a memory leak. af->data
contained a pointer to an allocated buffer, which was overwritten
during format negotiation. Set the format explicitly instead.
af_lavrresample: allow other ffmpeg sample formats for input/output

The format was locked to s16. Extend it to accept all other ffmpeg
sample formats, and even allow different in- and output formats. The
generic filter code will still insert af_format on format mismatches,
though.
af: remove automatically inserted filters on full reinit

Make sure automatically inserted filters are removed on full reinit
(they are re-added later if they are really needed). Automatically
inserted filters were never explicitly removed, instead, it was
expected that redundant conversion filters detach themselves. This
didn't work if there were several chained format conversion filters,
e.g. s16le->floatle->s16le, which could result from repeated filter
insertion and removal. (format filters detach only if input format and
output format are the same.)

Further, the dummy filter (which exists only because af.c can't handle
an empty filter chain for some reason) could introduce bad conversions
due to how the format negotiation works. Change the code so that the
dummy filter never takes part on format negotiation. (It would be better
to fix format negotiation, but that would be much more complicated and
would involving fixing all filters.)

Simplify af_reinit() and remove the start audio filter parameter. This
means format negotiation and filter initialization is run more often,
but should be harmless.
af: use af_lavrresample for format conversions, if possible

Refactor to remove the duplicated format filter insertion code. Allow
other format converting filters to be inserted on format mismatches.
af_info.test_conversion checks whether conversion between two formats
would work with the given filter; do this to avoid having to insert
multiple conversion filters at once and such things. (Although this
isn't ideal: what if we want to avoid af_format for some conversions?
What if we want to split af_format in endian-swapping filters etc.?)

Prefer af_lavrresample for conversions that it supports natively,
otherwise let af_format handle the full conversion.
af: factor channel filter insertion

Do this just like it has been done for the format filter.
af: simplification

If format negotiation fails, and additional filters are inserted to fix
this, don't try to reinitialize the filter immediately. Instead, correct
the audio format, and let the caller retry.

Add a retry counter to af_reinit() to ensure that misbehaving filters
can't put the format negotiation into an endless loop.