samplebuffer: fixed segfault when changing speed

This commit is contained in:
itsmattkc
2020-06-12 14:53:27 +10:00
parent 955d4ce910
commit 23365074f0
2 changed files with 6 additions and 8 deletions
+4 -4
View File
@@ -173,15 +173,15 @@ void SampleBuffer::speed(double speed)
return;
}
int max_adjusted_nb_samples = qRound(static_cast<double>(sample_count_per_channel_) * speed);
sample_count_per_channel_ = qRound(static_cast<double>(sample_count_per_channel_) / speed);
float** input_data = data_;
float** output_data;
allocate_sample_buffer(&output_data, audio_params_.channel_count(), max_adjusted_nb_samples);
allocate_sample_buffer(&output_data, audio_params_.channel_count(), sample_count_per_channel_);
for (int i=0;i<max_adjusted_nb_samples;i++) {
int input_index = qRound(static_cast<double>(i) * speed);
for (int i=0;i<sample_count_per_channel_;i++) {
int input_index = qFloor(static_cast<double>(i) * speed);
for (int j=0;j<audio_params_.channel_count();j++) {
output_data[j][i] = input_data[j][input_index];