ao_coreaudio: add more layout debug outputs

Should help remote debugging #1367 with --msg-level=ao=debug
ao_coreaudio: move some code to make output readable
ao_coreaudio: fix typo
ao_coreaudio: fix channel mapping

There where 3 major errors in the previous code:

1) The kAudioDevicePropertyPreferredChannelLayout selector returns a single
   layout not an array.
2) The check for AudioChannelLayout allocation size was wrong (didn't account
   for variable sized struct).
3) Didn't query the kAudioDevicePropertyPreferredChannelsForStereo selector
   since I didn't know about it's existence.

All of these are fixed.

Might help with #1367
player: cosmetics: rename a function

Something which has this many important sideffects shouldn't start have
a "get" prefix.
player: fix random crashes on uninitialization

On uninitialization, the player will unselect all subtitles, and then
destroy the subtitle decoder. But it didn't correctly remove the
subtitle decoder from the OSD state, so it could happen that it would
access it after the decoder was destroyed.

Could lead to random crashes when switching files often.

Fixes #1389.
player: force stereo as default when encoding

I think the new default for this option might be rather bad in encoding
mode. For starters, we don't even know what layers an encoder supports
at all.
ao_coreaudio: fix some naming conventions
ao_coreaudio: remove useless guard

useless after 069016fd6c
stream: always make stream dumping/capturing append to output file

Partially fixes #1393 (but not really).
command: stip path from playlist OSD display

But only if it's not e.g. a http URL.

Fixes #1388.
manpage: document new --stream-dump behavior

That's probably a good idea.
Add Javascript scripting support using MuJS

Implements JS with almost identical API to the Lua support, except:
- The global mp, mp.msg and mp.utils are always available
- On error return undefined and the error is at mp.last_error_string
- Timers are JS "standard" global set/clear Timeout/Interval/Immediate
- Supports CommonJS style modules/require
- At mp.utils: read_file (any), and load_file, run_file (for js files)
- Global print and dump functions
- mp.options currently not supported

Requires MuJS (clone, make, make install):
- http://mujs.com/ - git://git.ghostscript.com/mujs.git
- Mirror - https://github.com/ccxvii/mujs

Note: MuJS is a new project and this is probably its first major use outside
of MuPDF. Please keep an eye open for bugs.
js: Cleanups, simplified (mostly address pr1351 comments)

- Removed #ifdef for the options
- Arrange includes
- Simplified resume/suspend following 756ade
- Simplified file functions
- Style (mostly more braces)
- Removed likely unused APIs (the kb/mouse handling stuff remains for now)
- Removed commented out alternative/debug functions
- More documentation for module/require
- print is now msg.info instead of msg.warn
js: add Duktape support and build instructions

The support is implemented using a thin translation layer from MuJS -> Duktape
(AKA MUD) which, at compile time, translates most of MuJS APIs into Duktape's,
and adds small wrapper functions where no identical API is available.

The existing code is minimally touched and the MUD translation is applied
via mud_js.h (and controlled with MUD_HAVE_DUK).

mpv needs duktape.c and duktape.h at <mpv-src>/duktape in order to use it.

Duktape - http://duktape.org/
Sources (as archives) - http://duktape.org/download.html or after checking out
the latest tag from https://github.com/svaarala/duktape-releases.git .

Like MuJS, Duktape is also a new project, so keep an eye for bugs here too.