13
0

fix upsampling import of X-channel files where buffersize % X != 0

This commit is contained in:
Robin Gareus 2016-06-17 22:17:19 +02:00
parent f4047b9a26
commit 425c40ff08
2 changed files with 7 additions and 6 deletions

View File

@ -265,14 +265,14 @@ write_audio_data_to_new_files (ImportableSource* source, ImportStatus& status,
uint32_t read_count = 0;
while (!status.cancel) {
framecnt_t const nread = source->read (data.get(), nframes);
framecnt_t const nread = source->read (data.get(), nframes * channels);
if (nread == 0) {
break;
}
peak = compute_peak (data.get(), nread, peak);
peak = compute_peak (data.get(), nread * channels, peak);
read_count += nread;
read_count += nread / channels;
status.progress = 0.5 * read_count / (source->ratio() * source->length() * channels);
}
@ -294,7 +294,7 @@ write_audio_data_to_new_files (ImportableSource* source, ImportStatus& status,
uint32_t x;
uint32_t chn;
if ((nread = source->read (data.get(), nframes)) == 0) {
if ((nread = source->read (data.get(), nframes * channels)) == 0) {
#ifdef PLATFORM_WINDOWS
/* Flush the data once we've finished importing the file. Windows can */
/* cache the data for very long periods of time (perhaps not writing */

View File

@ -73,14 +73,15 @@ framecnt_t
ResampledImportableSource::read (Sample* output, framecnt_t nframes)
{
int err;
size_t bs = floor (blocksize / source->channels()) * source->channels();
/* If the input buffer is empty, refill it. */
if (_src_data.input_frames == 0) {
_src_data.input_frames = source->read (_input, blocksize);
_src_data.input_frames = source->read (_input, bs);
/* The last read will not be a full buffer, so set end_of_input. */
if ((framecnt_t) _src_data.input_frames < blocksize) {
if ((framecnt_t) _src_data.input_frames < bs) {
_end_of_input = true;
}