matroska: store segment/edition uids in a single structure

To support edition references in matroska chapters, editions need to be
remembered for each chapter and source. To facilitate easier management
of these now-paired uids, a single structure is used.
matroska: parse the requested edition for the segment reference
matroska: set the edition uid when reading a chapter reference
matroska: select the edition using the requested edition uid
matroska: refactor ordered chapter timeline building

This will need to be recursive to support chapters referencing ordered
editions in other files.
matroska: recursively search for referenced segments

When playing a Matroska file with ordered chapters, it may reference
another file by edition uid. When this edition is also ordered, it may
reference other files. When this occurs, the new segment/edition pair is
added to the list of sources to search for.
matroska: support chapter references to ordered editions

Since ordered editions can reference external files, when an ordered
chapter references another ordered edition, we have to go and figure out
what is is referencing as well.
mp_ring: fix mp_ring_read_cb() when read wraps around

previously, mp_ring_read_cb() would allow reading past the end of the
ringbuffer when buffered > available. mp_ring_read() had logic for
splitting the read into two, which I duplicated into mp_ring_read_cb().
matroska: avoid requesting the same source multiple times
matroska: use memmove when collapsing the source list down
cocoa_common: check if the screen has a menubar in a more generic way

Fixes #274
mpvcore/playlist.c: Avoid NULL reference in playlist_add_base_path()

Before this patch, those will cause a crash:

  mpv -playlist /dev/null
  mpv -playlist <(bla) # if the result of bla is empty

Signed-off-by: Mohammad Alsaleh <CE.Mohammad.AlSaleh@gmail.com>
Signed-off-by: Stefano Pigozzi <stefano.pigozzi@gmail.com>
cocoa: fix mouse wheel scrolling
cocoa: refactor precise scrolling to a separate method
libquvi9: work around insane interaction between libquvi and libkdecore

The primary effect of this commit is that it fixes playback resume if
libquvi 0.9 and German locale are used, and libkdecore is on the system.
(See github issue #279.)

libquvi uses libproxy to determine system-wide proxy settings. libproxy
in turn loads libkdecore (if present) to determine KDE proxy settings.
libkdecore has a global constructor, which calls setlocale(LC_ALL, ""),
switching the current locale from "C" to what the user's settings. This
breaks some basic C string processing functions. Note that the locale
won't be set on program start, but only when libproxy calls dlopen() on
its config_kde module, which actually causes libkdecore to be loaded and
initialized.

In particular, with German locale, snprintf() would use "," instead of
"." when formatting float values, which in combination with playback
resume, would lead to parse errors the next time mpv was started, which
is how this issue was found.

I'd consider this a bug with libkdecore or at least libproxy. No library
should ever even touch locale: it might break basic expectations on C
string handling functions, might override program settings, and it's not
thread-safe. But this is so nasty and severe, that a quick hack to fix
it hurts less.

See github issue #279 and KDE bug #325902.
options: --loop=N means playback N times, not N+1 times

The argument or this change is that --loop should set how often the
file is played, not the number of additional repeats.

Based on pull request 277, with additions to the manpage and removal
of "--loop=0".

Signed-off-by: wm4 <wm4@nowhere>
playlist: check for NULL on caller site

Letting some playlist functions randomly accept NULL, while others do
not isn't such a good idea.
command: don't allow changing volume if no audio initialized

Changing volume when audio is disabled was a feature request (github
issue #215), and was introduced with commit 327a779.

But trying to fix github issue #280 (volume is not correct in no-audio
mode, and if audio is re-enabled, the volume set in no-audio mode isn't
set), I concluded that it's not worth the trouble and the current
implementation is questionable all around. (For example, you can't
change the real volume in no-audio mode, even if the AO is open - this
could happen with gapless audio.) It's hard to get right, and the
current mixer code is already hilariously overcomplicated. (Virtually
all of mixer.c is an amalgamation of various obscure corner cases.)

So just remove this feature again.

Note that "options/volume" and "options/mute" still can be used in
idle mode to adjust the volume used next time, though these properties
can't be used during playback and thus not in audio-only mode.

Querying the volume still "works" in audio-only mode, though it can
return bogus values.
command: preferably show "add"/"cycle"/"set" command errors on OSD

Before this, they were shown on terminal only. Now they use the OSD
mechanism, which shows them on the video window or the terminal,
depending on settings and what's available.
cocoa: make --ontop also cover dock+menubar

This only shows any differences when mpv isn't frontmost and is in fullscreen.
Cmd+Tab overlay is still at a higher level as to avoid complete usability fail.