core: fix problems in video EOF detection

Fix a missing check that could sometimes result in video frames being
shown after specified end pts (end of timeline segment or --endpos).

Fix mistaken video EOF detection after aspect change in video stream,
when there is no current valid visible frame but the next frame is
already buffered in VO.
core: in VO flip timing, recheck time after OSD draw

Make the code read current real time again after drawing OSD. This
ensures time taken in OSD drawing is properly deducted from the
duration of the following sleep. The main practical effect is to avoid
the A-V field on the status line staying at a value a couple of
milliseconds above 0 (depending on VO).
input: stop trying to read terminal input on EOF

Stop trying to read terminal input if a read attempt returns EOF. The
most important case where this matters is when someone runs the player
with stdin redirected from /dev/null and without specifying
--no-consolecontrols. This used to cause 100% CPU load while paused,
as select() would continuously trigger on stdin (the need for
--no-consolecontrols was not apparent to people with older mplayer
versions, as input reading was less efficient and latencies like
hardcoded sleeps kept CPU use well below 100%). Now this will only
cause a "Dead key input" error message.
build: remove OS/2 support
ao_alsa: use "Master" mixer channel instead of "PCM" by default

Do this, because the "Master" channel normally provides proper mute
control.

The old default can be forced with: --mixer-channel=PCM
libao2: change control() types to enum, remove unused ones

Change the audio driver control() command argument from "int" to "enum
aocontrol". Remove unused control types (SET_DEVICE, GET_DEVICE,
QUERY_FORMAT, SET_PLUGIN_DRIVER, SET_PLUGIN_LIST). The QUERY_FORMAT
one looks like there's a possibility such functionality could be
useful in the future, but as ao_oss was the only driver to have an
actual implementation of it, the current code wasn't worth keeping.
audio: keep volume level internally (not only in AO)

Current volume was always queried from the the audio output driver (or
filter in case of --softvol). The only case where it was stored on
mixer level was that when turning off mute, volume was set to the
value it had before mute was activated. Change the mixer code to
always store the current target volume internally. It still checks for
significant changes from external sources and resets the internal
value in that case.

The main functionality changes are:

Volume will now be kept separately from mute status. Increasing or
decreasing volume will now change it relative to the original value
before mute, even if mute is implemented by setting AO level volume to
0. Volume changes no longer automatically disable mute. The exception
is relative changes up (like the volume increase key in default
keybindings); that's the only case which still disables mute.

Keeping the value internally avoids problems with granularity of
possible volume values supported by AO. Increase/decrease keys could
work unsymmetrically, or when specifying a smaller than default
--volstep, even fail completely. In one case occurring in practice, if
the AO only supports changing volume in steps of about 2 and rounds
down the requested volume, then volume down key would decrease by 4
but volume up would increase by 2 (previous volume plus or minus the
default change of 3, rounded down to a multiple of 2). Now, the
internal value will keep full precision.
audio: mixer: change logic for AOs with no volume control

The volume filter was automatically inserted if setting AO volume
failed. Remove that logic, and instead enable softvol mode fully if
querying current volume (which will happen before any set attempts)
fails. Fully switching to softvol mode is more robust, and any case
where the behavior would differ (the behavior is neither that both
querying/setting always work nor that both always fail) would have
been buggy.
audio: restore volume setting after AO reinit if needed

MPlayer volume control was originally implemented with the assumption
that it controls a system-wide volume setting which keeps its value
even if a process closes and reopens the audio device. However, this
is not actually true for --softvol mode or some audio output APIs that
only consider volume as a per-client setting for software mixing. This
could have annoying results, as the volume would be reset to a default
value if the AO was closed and reopened, for example whem moving to a
new file or crossing ordered chapter boundaries. Add code to set the
previous volume again after audio reinitialization if the current
audio chain is known to behave this way (softvol active or the AO
driver is known to not keep persistent volume externally).

This also avoids an inconsistency with the mute flag. The frontend
assumed the mute status is persistent across file changes, but it
could be similarly lost.

The audio drivers that are assumed to not keep persistent volume are:
coreaudio, dsound, esd, nas, openal, sdl. None of these changes have
been tested. I'm guessing that ESD and NAS do per-connection
non-persistent volume settings.

Partially based on code by wm4.
audio: restore balance setting after reinit

Restore the audio balance setting when the audio chain is
reinitialized (also after switching to another file).

Also add a note about the balance code being seriously buggy.
audio: fix unmute-at-end logic

The player tried to disable mute before exiting, so that if mute is
emulated by setting volume to 0 and the volume setting is a
system-global one, we don't leave it at 0. However, the logic doing
this at process exit was flawed, as volume settings are handled by
audio output instances and the audio output that set the mute state
may have been closed earlier. Trying to write reliably working logic
that restores volume at exit only would be tricky, so change the code
to always unmute an audio driver before closing it and restore mute
status if one is opened again later.
mixer: support native audio driver mute

Make mixer support setting the mute attribute at audio driver level,
if one exists separately from volume. As of this commit, no libao2
driver exposes such an attribute yet; that will be added in later
commits.

Since the mute status can now be set externally, it's no longer
completely obvious when the player should automatically disable mute
when uninitializing an audio output. The implemented behavior is to
turn mute off at uninitialization if we turned it on and haven't
noticed it turn off (by external means) since.
ao_alsa: support native mute control
ao_pulse: support native mute control
ao_coreaudio: fix partial volume control

If digital pass-through is used, this supported setting the volume
(just mute, actually), but not getting the volume. This will probably
lead to a stuck mute state in the mplayer frontend. Make the code
respond to volume queries even if digital pass-through is used.
stream_pvr: fix field size / snprintf size mismatch

struct station_elem_s had a field "name[8]", but the rest of the code
used PVR_STATION_NAME_SIZE as field size in snprintf and some other
calls accessing the field. Change the field size to
PVR_STATION_NAME_SIZE so it matches the accesses.
demux_lavf: try harder to make up a frame rate

Frame rate information is mostly irrelevant for playback, but it's
needed at least to convert frame numbers used in some subtitle formats
(like MicroDVD) into timestamps. Libavformat stopped making up a frame
rate if no "reliable" information is available (commit 7929e22bd
"lavf: don't guess r_frame_rate from either stream or codec timebase",
1.5 months ago). This caused a regression with AVI files and MicroDVD
subtitles. Add a heuristic similar to what libavformat used to have,
to make up FPS values which should work at least for the AVI+MicroDVD
use case.
subs: only use "subfont.ttf" as libass fallback if it exists

Libass was set to use the file "subfont.ttf" in the user configuration
directory as a default/fallback font. This triggered "Error opening
font" errors from libass if it tried to use the fallback font for some
glyph and the user had not copied/linked any font there (and there is
generally little reason to do that nowadays when using fontconfig).
Check whether the path exists and only set it in ass_set_fonts() if it
does.
Windows: Force Fontconfig scan
vf_gradfun: Comment out use of broken ASM until it’s fixed