libav: compatibility issues between libav and ffmpeg
authorLeandro Dorileo <leandro.maciel.dorileo@intel.com>
Thu, 13 Feb 2014 13:24:44 +0000 (11:24 -0200)
committerLeandro Dorileo <leandro.maciel.dorileo@intel.com>
Thu, 13 Feb 2014 15:18:13 +0000 (13:18 -0200)
For compatibility issues we must try to get channels using the
codec->channels field if it's 0 we try using the function
av_get_channel_layout_cb_channels().

src/plugins/generic/generic.c

index 4be6d60..d3a0069 100644 (file)
@@ -381,7 +381,11 @@ _parse_audio_stream(AVFormatContext *fmt_ctx, struct lms_audio_info *info, AVStr
     AVCodecContext *ctx = stream->codec;
 
     info->bitrate = ctx->bit_rate;
-    info->channels = av_get_channel_layout_nb_channels(ctx->channel_layout);
+    info->channels = ctx->channels;
+
+    if (!info->channels)
+        info->channels = av_get_channel_layout_nb_channels(ctx->channel_layout);
+
     info->sampling_rate = ctx->sample_rate;
     info->length = _get_stream_duration(fmt_ctx);