提交 decc19cc authored 作者: Travis Cross's avatar Travis Cross

Handle zero channels when allocating for resampler

When the number of channels was zero, we were calling malloc with a
size of zero.  While defined, this is unusual.  And since we're
initializing the speex resampler as though there were one channel in
this case, we should probably just allocate the space for it.
上级 164fa133
...@@ -78,7 +78,7 @@ SWITCH_DECLARE(switch_status_t) switch_resample_perform_create(switch_audio_resa ...@@ -78,7 +78,7 @@ SWITCH_DECLARE(switch_status_t) switch_resample_perform_create(switch_audio_resa
resampler->factor = (lto_rate / lfrom_rate); resampler->factor = (lto_rate / lfrom_rate);
resampler->rfactor = (lfrom_rate / lto_rate); resampler->rfactor = (lfrom_rate / lto_rate);
resampler->to_size = resample_buffer(to_rate, from_rate, (uint32_t) to_size); resampler->to_size = resample_buffer(to_rate, from_rate, (uint32_t) to_size);
resampler->to = malloc(resampler->to_size * sizeof(int16_t) * channels); resampler->to = malloc(resampler->to_size * sizeof(int16_t) * (channels ? channels : 1));
resampler->channels = channels; resampler->channels = channels;
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论