From a28ef704adf8c5bfa45b3d6285f741af64758ceb Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Thu, 8 Dec 2016 11:23:58 +0000 Subject: Further fixes and tidying to 'better-seek'. This fixes the failure to keep track of the `position' of each stream of a multi-stream file. It also tidies things up a bit. --- src/lib/audio_decoder.cc | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'src/lib/audio_decoder.cc') diff --git a/src/lib/audio_decoder.cc b/src/lib/audio_decoder.cc index fd0835596..1b1ae70c0 100644 --- a/src/lib/audio_decoder.cc +++ b/src/lib/audio_decoder.cc @@ -32,6 +32,7 @@ using std::cout; using std::map; using boost::shared_ptr; +using boost::optional; AudioDecoder::AudioDecoder (Decoder* parent, shared_ptr content, shared_ptr log) : DecoderPart (parent, log) @@ -83,7 +84,7 @@ AudioDecoder::give (AudioStreamPtr stream, shared_ptr data, void AudioDecoder::flush () { - for (map >::const_iterator i = _streams.begin(); i != _streams.end(); ++i) { + for (StreamMap::const_iterator i = _streams.begin(); i != _streams.end(); ++i) { i->second->flush (); } } @@ -92,7 +93,7 @@ void AudioDecoder::seek (ContentTime t, bool accurate) { _log->log (String::compose ("AD seek to %1", to_string(t)), LogEntry::TYPE_DEBUG_DECODE); - for (map >::const_iterator i = _streams.begin(); i != _streams.end(); ++i) { + for (StreamMap::const_iterator i = _streams.begin(); i != _streams.end(); ++i) { i->second->seek (t, accurate); } } @@ -100,7 +101,19 @@ AudioDecoder::seek (ContentTime t, bool accurate) void AudioDecoder::set_fast () { - for (map >::const_iterator i = _streams.begin(); i != _streams.end(); ++i) { + for (StreamMap::const_iterator i = _streams.begin(); i != _streams.end(); ++i) { i->second->set_fast (); } } + +optional +AudioDecoder::position () const +{ + optional pos; + for (StreamMap::const_iterator i = _streams.begin(); i != _streams.end(); ++i) { + if (!pos || (i->second->position() && i->second->position().get() < pos.get())) { + pos = i->second->position(); + } + } + return pos; +} -- cgit v1.2.3