Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FFmpeg 7.0でのAPI変更に伴うコンパイルエラーを修正 #1281

Open
wants to merge 2 commits into
base: v6_develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions Siv3D/src/Siv3D-Platform/Linux/Siv3D/AudioCodec/CAudioCodec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,10 +186,28 @@ namespace s3d
}

// initialize swr context
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(61, 3, 100)
AVChannelLayout out_channel_layout;
av_channel_layout_subset(&out_channel_layout, AV_CH_LAYOUT_STEREO);
#else
int64_t out_channel_layout = AV_CH_LAYOUT_STEREO;
#endif
int out_nb_samples = m_codec_context->frame_size;
AVSampleFormat out_sample_fmt = AV_SAMPLE_FMT_FLT;
m_out_sample_rate = m_codec_context->sample_rate;
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(61, 3, 100)
AVChannelLayout default_channel_layout;
av_channel_layout_default(&default_channel_layout, m_codec_context->ch_layout.nb_channels);
int allocation_result = swr_alloc_set_opts2(&m_swr_context,
&out_channel_layout, out_sample_fmt, m_out_sample_rate,
&default_channel_layout,
m_codec_context->sample_fmt, m_codec_context->sample_rate, 0, nullptr);
if (allocation_result < 0)
{
LOG_TRACE(U"AACDecoder: swr_alloc() failed ({})"_fmt(m_path));
return false;
}
#else
m_swr_context = swr_alloc_set_opts(m_swr_context,
out_channel_layout, out_sample_fmt, m_out_sample_rate,
av_get_default_channel_layout(m_codec_context->channels),
Expand All @@ -199,6 +217,7 @@ namespace s3d
LOG_TRACE(U"AACDecoder: swr_alloc() failed ({})"_fmt(m_path));
return false;
}
#endif
[[maybe_unused]] int averr = swr_init(m_swr_context);
if (swr_is_initialized(m_swr_context) == 0)
{
Expand All @@ -207,7 +226,11 @@ namespace s3d
}

// allocate output buffer
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(61, 3, 100)
int out_nb_channels = out_channel_layout.nb_channels;
#else
int out_nb_channels = av_get_channel_layout_nb_channels(out_channel_layout);
#endif
int buf_size = av_samples_get_buffer_size(nullptr,
out_nb_channels, out_nb_samples, out_sample_fmt, 0);
m_out_buf = (uint8_t*)av_malloc(buf_size);
Expand Down