summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2013-05-07 21:02:13 +0100
committerCarl Hetherington <cth@carlh.net>2013-05-07 21:02:13 +0100
commit1f4a21c0da3a917a5ff7743a577cc0f210fa86d8 (patch)
tree82ed1f862a05eea69d4fb6f9ec946adb264f3568 /src
parent188a4c094775a0fa8b69722bba7c18ae3e2bb5d3 (diff)
Stop SndfileDecoder with no audio emitting lots of silence.
Diffstat (limited to 'src')
-rw-r--r--src/lib/sndfile_decoder.cc6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/lib/sndfile_decoder.cc b/src/lib/sndfile_decoder.cc
index fdaf2eeaa..d70478a1b 100644
--- a/src/lib/sndfile_decoder.cc
+++ b/src/lib/sndfile_decoder.cc
@@ -102,14 +102,20 @@ SndfileDecoder::pass ()
sf_count_t const block = _audio_stream->sample_rate() / 2;
shared_ptr<AudioBuffers> audio (new AudioBuffers (_audio_stream->channels(), block));
sf_count_t const this_time = min (block, _frames - _done);
+ bool have_sound = false;
for (size_t i = 0; i < _sndfiles.size(); ++i) {
if (!_sndfiles[i]) {
audio->make_silent (i);
} else {
sf_read_float (_sndfiles[i], audio->data(i), this_time);
+ have_sound = true;
}
}
+ if (!have_sound) {
+ return true;
+ }
+
audio->set_frames (this_time);
Audio (audio, double(_done) / _audio_stream->sample_rate());
_done += this_time;