Stream timing information provided are current position and total duration.

The timing information can either be derived from timestamps provided
at certain points in the stream and the number of samples played/decoded.

These timestamps are either embedded in the stream (format specific, may
not have any) or in the case of a circular input buffer controlled by an
external application defined by calling SWI StreamDecoding, 10 before
adding the corresponding input to the buffer.

For the last situation, the application maintains a list of time markers
for both the input and output. For input:

TimeMarker.time = time in milliseconds
TimeMarker.position = pos in input buffer

For output, monotonicly increasing counters of samples played/decoded
are maintained to define output time markers:

s->codec.samples.played = nr of samples played
s->codec.samples.decoded = nr of samples decoded

TimeMarker.time = time in milliseconds
TimeMarker.position = nr of samples

The input will be decoded in chunks up to the next input marker,
a corresponding output marker is added to the list with
s->codec.samples.decoded as position and the input marker is removed.

When the output is written to the sound buffers, if s->codec.samples.played
goes past the next output marker, this one is copied as new refTime
and removed from the list.

s->info.reftime = current reference (time, nr of samples)

As special cases output time markers will be inserted automatically
when StreamPosition is used to alter the position or when moving back
to the start of the stream.


The codecs themselves provides the current position and total duration
as well as update s->codec.samples.played and s->codec.samples.decoded.
To help them they usually maintain the following variables:

w->last_free = output end last time we updated s->codec.samples.decoded
w->playedsamples = nr of samples played from start (incorrect if setpos used)
w->totalsamples  = estimated total nr of samples in stream

For formats whithout timestamps:
current time = s->info.reftime.time
             + tomilli(s->codec.samples.played - s->info.reftime.position);
duration = tomilli(stream size, mean bitrate)
           or if we decoded the stream from start to end,
           the total nr of decoded samples.

For Ogg Vorbis, timing is provided by the external Vorbis decode module.
For FLAC, timing calculation is derived from the index of the first sample
in each frame.
