summaryrefslogtreecommitdiff
path: root/src/lib/ffmpeg_decoder.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2012-10-31 01:13:52 +0000
committerCarl Hetherington <cth@carlh.net>2012-10-31 01:13:52 +0000
commita3215474d871d075a449dbcff2cb5a3b0daa1720 (patch)
tree6f56dc61c0310e57317f77f2749c08d8bd7c19f9 /src/lib/ffmpeg_decoder.cc
parenteadfcc15aa8d0c12e0e26197750e4b12a9ab8262 (diff)
Don't emit 0 bytes of audio if video and audio are already in sync.
Diffstat (limited to 'src/lib/ffmpeg_decoder.cc')
-rw-r--r--src/lib/ffmpeg_decoder.cc26
1 files changed, 14 insertions, 12 deletions
diff --git a/src/lib/ffmpeg_decoder.cc b/src/lib/ffmpeg_decoder.cc
index e9d107a89..5b96d899a 100644
--- a/src/lib/ffmpeg_decoder.cc
+++ b/src/lib/ffmpeg_decoder.cc
@@ -326,29 +326,31 @@ FFmpegDecoder::do_pass ()
_first_audio = pts_seconds;
/* This is our first audio packet, and if we've arrived here we must have had our
- first video packet. Push some silence to make up the gap between our first
+ first video packet. Push some silence to make up any gap between our first
video packet and our first audio.
*/
/* frames of silence that we must push */
int const s = rint ((_first_audio.get() - _first_video.get()) * audio_sample_rate ());
-
+
_film->log()->log (
String::compose (
"First video at %1, first audio at %2, pushing %3 frames of silence for %4 channels (%5 bytes per sample)",
_first_video.get(), _first_audio.get(), s, audio_channels(), bytes_per_audio_sample()
)
);
-
- /* hence bytes */
- int const b = s * audio_channels() * bytes_per_audio_sample();
-
- /* XXX: this assumes that it won't be too much, and there are shaky assumptions
- that all sound representations are silent with memset()ed zero data.
- */
- uint8_t silence[b];
- memset (silence, 0, b);
- process_audio (silence, b);
+
+ if (s) {
+ /* hence bytes */
+ int const b = s * audio_channels() * bytes_per_audio_sample();
+
+ /* XXX: this assumes that it won't be too much, and there are shaky assumptions
+ that all sound representations are silent with memset()ed zero data.
+ */
+ uint8_t silence[b];
+ memset (silence, 0, b);
+ process_audio (silence, b);
+ }
}
int frame_finished;