summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2015-04-12 20:23:19 +0200
committerBent Bisballe Nyeng <deva@aasimon.org>2015-04-12 20:23:19 +0200
commitfcfa4676a2be89fff6ea55ff13c5e3e73ba59a74 (patch)
tree9d15906b224e4f29c9bd1f035c937a01260af366 /src
parente80ac13bfb7a16a79dc96f94c5816b7089b62efa (diff)
Fix partial loading of multichannel files.
Diffstat (limited to 'src')
-rw-r--r--src/audiofile.cc4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/audiofile.cc b/src/audiofile.cc
index 59e0c14..f6a2c1d 100644
--- a/src/audiofile.cc
+++ b/src/audiofile.cc
@@ -139,10 +139,10 @@ void AudioFile::load(int num_samples)
int read;
do {
read = sf_readf_float(fh, buffer, readsize);
- for (int i = 0; i < read; i++) {
+ for (int i = 0; i < read && totalread < num_samples; i++) {
data[totalread++] = buffer[i * sf_info.channels + filechannel];
}
- } while(read > 0 && totalread < (int)size);
+ } while(read > 0 && totalread < (int)size && totalread < num_samples);
// set data size to total bytes read
size = totalread;
}