audio/out/push: fix EOF heuristic

Since the internal AO driver API has no proper way to determine EOF, we
need to guess by querying get_delay. But some AOs (e.g. ao_pulse with
no-latency-hacks set) may never reach 0, maybe because they naively add
the latency to the buffer level. In this case our heuristic can break.

Fix by always using the delay to estimate the EOF time. It's not even
that important - it's mostly used to avoid blocking draining. So this
should be ok.

CC: @mpv-player/stable (maybe)
audio/out/push: make draining slightly more robust

Don't wait after the audio thread has pushed the remaining audio to the
AO. Avoids hard hangs if the heuristic fails completely (could still
happen if get_delay returns absurd values).

CC: @mpv-player/stable
Add some missing "const"s

The one in msg.c was mistakenly removed with commit e99a37f6.

I didn't actually test the change in ao_sndio.c (but obviously "ap"
shouldn't be static).
Revert "player: --save-position-on-quit should always work"

This reverts commit 45c8b97efbaff7a5031b008223eeed56f7b0607a.

Some else complained (github issue #1163).

The feature requested in #1148 will be implemented differently in
the following commit.
player: --save-position-on-quit should always work (2)

This reimplements the feature reverted in the previous commit in a
different way.
player: don't close audio device in gapless mode

I don't see much of a reason for this extra corner case.
player: minor simplification
player: signal EOF when using --frames
player: exit if audio init fails and there's no video

Seems logical. For some reason, the player allows deselecting both audio
and video stream without quitting (a deliberate feature of which I have
no idea why it was added years ago), so this is needed.
audio: change internal device listing API

Now we run ao_driver->list_devs on a dummy AO instance, which will
probably confuse everyone. This is done for the sake of PulseAudio.
ao_pulse: move setup code to separate function

All the dumb crap in pa_init_boilerplate() is needed to talk to the
audio server at all. Might also fix some subtle bugs in the init code
(which is strange, because the original file was contributed by the
devil himself).
ao_pulse: implement AO device listing API

While conceptually this sink stuff in PulseAudio does just the right
thing, actually listing the sinks is unbelievable complicated. Not only
is the idea that listing them should happen asynchronously completely
bullshit (who the fuck runs the PulseAudio server on a separate
computer), but the way this is done is full of bullshit too. Why
separate callbacks for each device? Why this obtuse mainloop shit?
Especially the mainloop shit makes it actively worse than doing things
manually with pthread primitives, and the reason for that (different
mainloop implementations for GUIs?) is laughable too. It's like they
chose the most complicated API possible just because they attempted
to "abstract" basic mechanisms in order to handle "everything". While
I don't claim to design the best APIs, this API is fucking terrible
without any excuse. (End of rant.)
player: don't mess up cursor visibility state

Manually setting can break things forever, because it puts the VO cursor
state out of sync with the remembered state by handle_cursor_autohide().
Use the normal autohide code during idle mode too instead. (Originally
the idea was to make the cursor always visible in idle mode, but not so
important.)

Regression since e1e8b07c. Fixes #1166.

CC: @mpv-player/stable
player: fix terminal status in idle mode

That's what this variable is for. This was missed in commit 9d5d031b.
audio: don't list encoder AO with --audio-device=help
command: make audio device list available to the client API
input: add a function to parse mpv_node as command

For future client API enhancements.
input: use mpv_node parser for char** command parsers

Minor simplification, also drops some useless stuff.
input: cosmetics: move code
input: remove some unneeded code