demux_mkv: fix possible real-audio out of bounds accesses

Could index static arrays from arbitrary input data without checking for
bounds.

Found by Coverity.
demux_mkv: fix scary sign extension issues

Expressions involving uint16_t are promoted to int, which then can
overflow if the uint16_t values are large enough.

Found by Coverity.
ipc: fix confusion of write() return value and errno

Found by Coverity.
Remove some superfluous NULL checks

In all of these situations, NULL is logically not allowed, making the
checks redundant.

Coverity complained about accessing the pointers before checking them
for NULL later.
bstr: don't call memcpy(..., NULL, 0)

This is clearly not allowed, although it's not a problem on most libcs.

Found by Coverity.
stream: fix endian swapping

In addition to the messed-up expression, the endianness was also
inverted. The code reads big endian by default.

It "worked" by coincidence, but for little endian, codepoints outside of
latin1 were broken.

The broken expression was found by Coverity.