package: performous
Version: 1.3.0+dfsg-1

The source code of performous is incompatible with the current version of 
FFmpeg 7, leading to a crash when trying to compile against it.
The attached patch fixes the issues, allowing successful compilation.

I am using Ubuntu 24.04 and Debian Unstable.
diff -Nru performous-1.3.0+ds.orig/game/ffmpeg.cc 
performous-1.3.0+ds/game/ffmpeg.cc
--- performous-1.3.0+ds.orig/game/ffmpeg.cc     2024-09-10 14:00:52.414736705 
-0400
+++ performous-1.3.0+ds/game/ffmpeg.cc  2024-09-10 18:32:16.119087659 -0400
@@ -290,8 +290,18 @@
                // 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);
+               if (av_channel_layout_check(&m_codecContext->ch_layout)) {
+                       av_opt_set_chlayout(m_resampleContext.get(), 
"in_channel_layout",&m_codecContext->ch_layout, 0);
+               } else {
+                       AVChannelLayout ch_layout_in;
+                       av_channel_layout_default(&ch_layout_in, 
m_codecContext->ch_layout.nb_channels);
+                       av_opt_set_chlayout(m_resampleContext.get(), 
"in_channel_layout", &ch_layout_in, 0);
+                       av_channel_layout_uninit(&ch_layout_in);
+               }
+               AVChannelLayout ch_layout_out;
+               av_channel_layout_default(&ch_layout_out, AUDIO_CHANNELS);
+               av_channel_layout_uninit(&ch_layout_out);
+               av_opt_set_chlayout(m_resampleContext.get(), 
"out_channel_layout", &ch_layout_out, 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);

Reply via email to