- resampler = swr_alloc_set_opts(nullptr,
- /*out_ch_layout=*/AV_CH_LAYOUT_STEREO,
- /*out_sample_fmt=*/ctx->sample_fmt,
- /*out_sample_rate=*/OUTPUT_FREQUENCY,
- /*in_ch_layout=*/AV_CH_LAYOUT_STEREO,
- /*in_sample_fmt=*/AV_SAMPLE_FMT_FLT,
- /*in_sample_rate=*/OUTPUT_FREQUENCY,
- /*log_offset=*/0,
- /*log_ctx=*/nullptr);
- if (resampler == nullptr) {
+ resampler = nullptr;
+ int ok = swr_alloc_set_opts2(&resampler,
+ /*out_ch_layout=*/&ctx->ch_layout,
+ /*out_sample_fmt=*/ctx->sample_fmt,
+ /*out_sample_rate=*/OUTPUT_FREQUENCY,
+ /*in_ch_layout=*/&ctx->ch_layout,
+ /*in_sample_fmt=*/AV_SAMPLE_FMT_FLT,
+ /*in_sample_rate=*/OUTPUT_FREQUENCY,
+ /*log_offset=*/0,
+ /*log_ctx=*/nullptr);
+ if (ok != 0) {