core, timeline: don't keep separate stream field

The timeline code kept pairs of struct stream and struct demuxer
around. The reference to the stream is redundant, because we always
create a demuxer for the stream. Simply it by always accessing the
stream through the demuxer references, instead of keeping the redundant
stream reference around.

Also, set mpctx->stream to the current segment when using timeline.

Fix a small memory leak in tl_matroska.c introduced earlier.
command: remove sub_log command

Not very useful, and introduced special cases. Just get rid of it, can
be reintroduced if in a better way if someone misses this feature.
command: remove sub_remove command

This messes deeply with the subtitle bookkeeping data structures, and
would have to be reimplemented anyway.

It's not sure what this was even useful for. Possibly for slave mode.
core: refactor MPContext.demuxer field accesses

Whenever the demuxer is accessed to retrieve metadata, use the newly
introduced master_demuxer field instead. If a timeline is used, the
master_demuxer will still refer to the main file, instead to segments.

Instead of mpctx->demuxer->stream, access mpctx->stream; even though
they are the same, the code becomes shorter. For the TV code, introduce
a function get_tvh() to access the TV handle, instead of duplicating the
code all over the place. Often the demuxer field is checked to determine
whether something is currently played; prefer other methods over that.

Note that the code before always accessed the current timeline segment,
and would e.g. read file metadata of the current segment. Now it always
returns metadata for the master file. There may have various wanted and
unwanted effects.
core: manage tracks in the frontend

Introduce a general struct track for every audio/video/subtitle track
known to the frontend. External files (subtitles) are now represented
as tracks too. This mainly serves to clean up the subtitle selection
code: now every subtitle is simply a track, instead of using a messy
numbering that goes by subtitle type (it was stored in the
global_sub_pos field). Managing external subtitle files is now done
with track handling. The mplayer fontend will list external subtitle
files as additional tracks.

Track cycling is now done by the fronend, instead of the individual
demuxers.

The timeline code now tries to match the exact demuxer IDs of all
tracks. This may cause problems when Matroska files with different
track numberings are used with EDL timelines. Change demux_lavf not
to set demuxer IDs, since most time they are not set.
core: move support -audiofile to the frontend
mplayer: do not cancel playback if VF/VO config fails

Usually failing to initialize the video chain does not stop playback,
and continues with audio-only. But when VF/VO config failed (the second
step in initializing them), playback was canceled and advanced to the
next file.

Make it more consistent and just switch off video if it fails.

Also, if no audio track is selected, go to next file anyway. The player
core goes into some sort of idle mode if no video and audio track is
selected, and we don't want to trigger it here. (It's unclear whether
that is a bug or feature: it's meant to work around some corner cases,
but maybe it shouldn't be triggered when switching off video & audio
tracks in normal playback.)
video_out: free memory if initializing a VO fails

This was a minor memory leak with no real impact.
core: runtime Matroska edition switching

Add a new slave property which switches the current Matroska edition.
Since each edition can define an entirely new timeline, switching the
edition will simply restart playback at the beginning of the file with
the new edition selected.

Add 'E' as new keybinding to step the edition property.

DVD titles are still separate. Apparently they work similarly, but I
don't have any multi-title DVDs for testing. Also, cdda (for audio CDs)
uses the same mechanism as DVDs to report a number of titles, so there
seems to be confusion what exactly this mechanism is supposed to do.
For this reason, the edition code is completely separate.

Remove demuxer.num_titles, it was just a rather useless cached value of
the DVD titles related STREAM_CTRL.

One rather obscure corner case isn't taken care of: if the ordered
chapters file has file local options set, they are reset on playback
restart. This is unexpected, because edition switching is meant to look
like seeking back to the beginning of the file.
mplayer: don't clear OSD when new file is played

When switching editions, it would be nice to display an OSD message to
notify the user which edition is being played. This would be consistent
with visual feedback like on tracking switching, seeking, and so on.

Rather than introducing awkward hacks and special cases to determine
whether a file is being "restarted" (as it happens on edition switching)
to avoid clearing the OSD messages, simply never clear the OSD stack.

This is more consistent with handling of OSD bars too: they didn't
disappear when going to a new file (especially noticable when seeking
past the end of the file).
demuxer: fix DVD subtitle language display with demux_lavf

demux_mpg, which was the default demuxer for DVD playback, reordered
the subtitle streams according to the logical subtitle track number,
which is what stream_dvd expects for the STREAM_CTRL_GET_LANG call.
demux_lavf, on the other hand, adds the stream in the order it
encounters them in the MPEG stream. It seems this order is essentially
random, and can't be mapped to what stream_dvd expects.

Solve this by making demux_lavf hand out the MPEG stream IDs (using the
demuxer_id field). The MPEG IDs are passed to stream_dvd, which then
uses the same logic as demux_mpg to convert them to the logical track
number (or whatever the proper term is).

Note that demux_lavf doesn't export stream IDs for other formats,
because most time libavformat demuxers do not set AVStream.id, and we
don't know which demuxers do. But we know that MPEG is safe.
mplayer: add all DVD subtitle tracks in advance

This restores track selection with DVDs back to the state before the
commit "core: manage tracks in the frontend". Note that this still
doesn't work properly when using DVDs with demux_lavf.
demux_mkv: fix minor memory leak