Skip to content

Commit

Permalink
FFmpeg 7.0でのAPI変更に伴うコンパイルエラーを修正
Browse files Browse the repository at this point in the history
  • Loading branch information
aFumihikoKobayashi authored Jan 1, 2025
1 parent 71f5f27 commit 4f07ca9
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions Siv3D/src/Siv3D-Platform/Linux/Siv3D/AudioCodec/CAudioCodec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,15 +186,18 @@ namespace s3d
}

// initialize swr context
int64_t out_channel_layout = AV_CH_LAYOUT_STEREO;
AVChannelLayout out_channel_layout;
av_channel_layout_subset(&out_channel_layout, AV_CH_LAYOUT_STEREO);
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;
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),
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 (m_swr_context == nullptr)
if (allocation_result < 0)
{
LOG_TRACE(U"AACDecoder: swr_alloc() failed ({})"_fmt(m_path));
return false;
Expand All @@ -207,7 +210,7 @@ namespace s3d
}

// allocate output buffer
int out_nb_channels = av_get_channel_layout_nb_channels(out_channel_layout);
int out_nb_channels = out_channel_layout.nb_channels;
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

0 comments on commit 4f07ca9

Please sign in to comment.