diff options
author | Bent Bisballe Nyeng <deva@aasimon.org> | 2015-04-12 20:23:19 +0200 |
---|---|---|
committer | Bent Bisballe Nyeng <deva@aasimon.org> | 2016-01-20 13:23:13 +0100 |
commit | 2af32535862d1ffea36803a92a13d1fd013145a9 (patch) | |
tree | 7c1047411d29bbf552b64d5b845b9c597c730437 | |
parent | a95593343bfa82c14c9bea9dba92d16c6860b3e2 (diff) |
Fix partial loading of multichannel files.
-rw-r--r-- | src/audiofile.cc | 4 |
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; } |