]> git.sesse.net Git - nageru/commitdiff
Fix channel layout deprecations in AudioEncoder.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Sun, 1 Oct 2023 08:42:55 +0000 (10:42 +0200)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Sun, 1 Oct 2023 08:42:55 +0000 (10:42 +0200)
nageru/audio_encoder.cpp

index 4d42b4033c2a01052e41359005a897066c2fd426..126e0e2dce19ef40f0406bea7a3d4abed120c731 100644 (file)
@@ -51,16 +51,17 @@ AudioEncoder::AudioEncoder(const string &codec_name, int bit_rate, const AVOutpu
                abort();
        }
 
-       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) {
                fprintf(stderr, "Allocating resampler failed.\n");
                abort();
        }