summaryrefslogtreecommitdiff
path: root/src/lib/silence_decoder.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2013-05-23 17:18:49 +0100
committerCarl Hetherington <cth@carlh.net>2013-05-23 17:18:49 +0100
commit64a2f1bb6a7b972607fa363631ef7a47444e8217 (patch)
tree020c028a93f113e372e70f485857ce04dea5db3d /src/lib/silence_decoder.cc
parent8c6fe8e1e8c8f6d5932606f2a5b6e1b87681ae38 (diff)
Various bits and pieces.
Diffstat (limited to 'src/lib/silence_decoder.cc')
-rw-r--r--src/lib/silence_decoder.cc56
1 files changed, 56 insertions, 0 deletions
diff --git a/src/lib/silence_decoder.cc b/src/lib/silence_decoder.cc
new file mode 100644
index 000000000..9eee5bb10
--- /dev/null
+++ b/src/lib/silence_decoder.cc
@@ -0,0 +1,56 @@
+/*
+ Copyright (C) 2013 Carl Hetherington <cth@carlh.net>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+#include "silence_decoder.h"
+#include "null_content.h"
+#include "audio_buffers.h"
+
+using std::min;
+using boost::shared_ptr;
+
+SilenceDecoder::SilenceDecoder (shared_ptr<const Film> f, shared_ptr<NullContent> c)
+ : Decoder (f)
+ , AudioDecoder (f, c)
+{
+
+}
+
+void
+SilenceDecoder::pass ()
+{
+ shared_ptr<const Film> film = _film.lock ();
+ assert (film);
+
+ Time const this_time = min (_audio_content->length() - _next_audio, TIME_HZ / 2);
+ shared_ptr<AudioBuffers> data (new AudioBuffers (MAX_AUDIO_CHANNELS, film->time_to_audio_frames (this_time)));
+ data->make_silent ();
+ audio (data, _next_audio);
+}
+
+void
+SilenceDecoder::seek (Time t)
+{
+ _next_audio = t;
+}
+
+Time
+SilenceDecoder::next () const
+{
+ return _next_audio;
+}