20 lines
1.4 KiB
Diff
20 lines
1.4 KiB
Diff
|
diff --git a/game/ffmpeg.cc b/game/ffmpeg.cc
|
||
|
index db204fb8..528902a5 100644
|
||
|
--- a/game/ffmpeg.cc
|
||
|
+++ b/game/ffmpeg.cc
|
||
|
@@ -290,8 +290,12 @@ AudioFFmpeg::AudioFFmpeg(fs::path const& filename, int rate, AudioCb audioCb) :
|
||
|
// setup resampler
|
||
|
m_resampleContext.reset(swr_alloc());
|
||
|
if (!m_resampleContext) throw std::runtime_error("Cannot create resampling context");
|
||
|
- av_opt_set_int(m_resampleContext.get(), "in_channel_layout", m_codecContext->channel_layout ? static_cast<std::int64_t>(m_codecContext->channel_layout) : av_get_default_channel_layout(m_codecContext->channels), 0);
|
||
|
- av_opt_set_int(m_resampleContext.get(), "out_channel_layout", av_get_default_channel_layout(AUDIO_CHANNELS), 0);
|
||
|
+ AVChannelLayout in_layout;
|
||
|
+ AVChannelLayout out_layout;
|
||
|
+ av_channel_layout_default(&in_layout, m_codecContext->ch_layout.nb_channels);
|
||
|
+ av_channel_layout_default(&out_layout, AUDIO_CHANNELS);
|
||
|
+ av_opt_set_int(m_resampleContext.get(), "in_channel_layout", m_codecContext->ch_layout.u.mask ? static_cast<std::int64_t>(m_codecContext->ch_layout.u.mask) : in_layout.nb_channels, 0);
|
||
|
+ av_opt_set_int(m_resampleContext.get(), "out_channel_layout", out_layout.nb_channels, 0);
|
||
|
av_opt_set_int(m_resampleContext.get(), "in_sample_rate", m_codecContext->sample_rate, 0);
|
||
|
av_opt_set_int(m_resampleContext.get(), "out_sample_rate", static_cast<int>(m_rate), 0);
|
||
|
av_opt_set_int(m_resampleContext.get(), "in_sample_fmt", m_codecContext->sample_fmt, 0);
|