summaryrefslogtreecommitdiff
path: root/src/lib/audio_decoder.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2016-12-08 11:23:58 +0000
committerCarl Hetherington <cth@carlh.net>2016-12-08 11:23:58 +0000
commita28ef704adf8c5bfa45b3d6285f741af64758ceb (patch)
tree04c1afa7b6a72f7faabe290d14713d242b867ab1 /src/lib/audio_decoder.cc
parent804f43474bba7008bf68fc9189793c89c512a944 (diff)
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.
Diffstat (limited to 'src/lib/audio_decoder.cc')
-rw-r--r--src/lib/audio_decoder.cc19
1 files changed, 16 insertions, 3 deletions
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<const AudioContent> content, shared_ptr<Log> log)
: DecoderPart (parent, log)
@@ -83,7 +84,7 @@ AudioDecoder::give (AudioStreamPtr stream, shared_ptr<const AudioBuffers> data,
void
AudioDecoder::flush ()
{
- for (map<AudioStreamPtr, shared_ptr<AudioDecoderStream> >::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<AudioStreamPtr, shared_ptr<AudioDecoderStream> >::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<AudioStreamPtr, shared_ptr<AudioDecoderStream> >::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<ContentTime>
+AudioDecoder::position () const
+{
+ optional<ContentTime> 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;
+}