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];
+2 -4
View File
@@ -110,11 +110,9 @@ NodeValueTable RenderWorker::GenerateBlockTable(const TrackOutput *track, const
// Destination buffer
NodeValueTable table = GenerateTable(b, range_for_block);
QVariant sample_val = table.Take(NodeParam::kSamples);
SampleBufferPtr samples_from_this_block;
SampleBufferPtr samples_from_this_block = table.Take(NodeParam::kSamples).value<SampleBufferPtr>();
if (sample_val.isNull()
|| !(samples_from_this_block = sample_val.value<SampleBufferPtr>())) {
if (!samples_from_this_block) {
// If we retrieved no samples from this block, do nothing
continue;
}