samplebuffer: fixed segfault when changing speed
This commit is contained in:
@@ -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];
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user