Skip to content

Commit

Permalink
avcodec: adapt to ffmpeg-7
Browse files Browse the repository at this point in the history
ffmpeg-7 removed long deprecated API of accessing channels. As a result
`xmms2` fails the build now against `ffmpeg-7.0.2` as:

    ../src/plugins/avcodec/avcodec.c: In function ‘xmms_avcodec_init’:
    ../src/plugins/avcodec/avcodec.c:225:23: error: ‘AVCodecContext’ has no member named ‘channels’
      225 |         data->codecctx->channels = data->channels;
          |                       ^~

The change follows a trivial change of switching to new style similar to
upstream example update at:

    https://git.ffmpeg.org/gitweb/ffmpeg.git/commitdiff/f5ef91e02080316f50d606f5b0b03333bb627ed7
  • Loading branch information
trofi committed Sep 21, 2024
1 parent 899818f commit 0f056b7
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/plugins/avcodec/avcodec.c
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ xmms_avcodec_init (xmms_xform_t *xform)

data->codecctx = avcodec_alloc_context3 (codec);
data->codecctx->sample_rate = data->samplerate;
data->codecctx->channels = data->channels;
data->codecctx->ch_layout.nb_channels = data->channels;
data->codecctx->bit_rate = data->bitrate;
data->codecctx->bits_per_coded_sample = data->samplebits;
data->codecctx->block_align = data->block_align;
Expand Down Expand Up @@ -250,7 +250,7 @@ xmms_avcodec_init (xmms_xform_t *xform)
}

data->samplerate = data->codecctx->sample_rate;
data->channels = data->codecctx->channels;
data->channels = data->codecctx->ch_layout.nb_channels;
data->sampleformat = xmms_avcodec_translate_sample_format (data->codecctx->sample_fmt);
if (data->sampleformat == XMMS_SAMPLE_FORMAT_UNKNOWN) {
avcodec_close (data->codecctx);
Expand All @@ -270,7 +270,7 @@ xmms_avcodec_init (xmms_xform_t *xform)

XMMS_DBG ("Decoder %s at rate %d with %d channels of format %s initialized",
codec->name, data->codecctx->sample_rate,
data->codecctx->channels,
data->codecctx->ch_layout.nb_channels,
av_get_sample_fmt_name (data->codecctx->sample_fmt));

return TRUE;
Expand Down Expand Up @@ -504,7 +504,7 @@ xmms_avcodec_internal_append (xmms_avcodec_data_t *data)
{
enum AVSampleFormat fmt = (enum AVSampleFormat) data->read_out_frame->format;
int samples = data->read_out_frame->nb_samples;
int channels = data->codecctx->channels;
int channels = data->codecctx->ch_layout.nb_channels;
int bps = av_get_bytes_per_sample (fmt);

if (av_sample_fmt_is_planar (fmt)) {
Expand Down

0 comments on commit 0f056b7

Please sign in to comment.