This fixes missing mp3 channel data in the FFmpeg demuxer.
-- v2: winedmo: Find mp3 stream info if channel data is missing.
From: Brendan McGrath bmcgrath@codeweavers.com
--- dlls/winedmo/unix_demuxer.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
diff --git a/dlls/winedmo/unix_demuxer.c b/dlls/winedmo/unix_demuxer.c index 15d906e0c5f..5e22aaf9a81 100644 --- a/dlls/winedmo/unix_demuxer.c +++ b/dlls/winedmo/unix_demuxer.c @@ -124,6 +124,17 @@ static NTSTATUS demuxer_create_streams( struct demuxer *demuxer ) continue; } } + else if (par->codec_id == AV_CODEC_ID_MP3) + { + int channels; +#if LIBAVUTIL_VERSION_MAJOR >= 58 + channels = demuxer->ctx->streams[i]->codecpar->ch_layout.nb_channels; +#else + channels = demuxer->ctx->streams[i]->codecpar->channels; +#endif + if (!channels) + avformat_find_stream_info(demuxer->ctx, NULL); + }
av_bsf_get_null_filter( &stream->filter ); avcodec_parameters_copy( stream->filter->par_in, demuxer->ctx->streams[i]->codecpar );
Rémi Bernon (@rbernon) commented about dlls/winedmo/unix_demuxer.c:
continue; } }
else if (par->codec_id == AV_CODEC_ID_MP3)
{
int channels;
+#if LIBAVUTIL_VERSION_MAJOR >= 58
channels = demuxer->ctx->streams[i]->codecpar->ch_layout.nb_channels;
+#else
channels = demuxer->ctx->streams[i]->codecpar->channels;
+#endif
if (!channels)
avformat_find_stream_info(demuxer->ctx, NULL);
}
```suggestion:-10+0 else if (par->codec_id == AV_CODEC_ID_MP3) { int channels; #if LIBAVUTIL_VERSION_MAJOR >= 58 channels = par->ch_layout.nb_channels; #else channels = par->channels; #endif if (!channels) avformat_find_stream_info( demuxer->ctx, NULL ); } ```
But I wonder if this is this the best way to do this. Maybe we should call `avformat_find_stream_info` unconditionally for some formats. It was avoided because it can take a bit more time and we want demuxer initialization to be fastest as possible (to match native and address some Unreal Engine potential race condition), but that's maybe only specific to MP4 as far as I know.
On Fri Feb 28 07:40:35 2025 +0000, Rémi Bernon wrote:
else if (par->codec_id == AV_CODEC_ID_MP3) { int channels; #if LIBAVUTIL_VERSION_MAJOR >= 58 channels = par->ch_layout.nb_channels; #else channels = par->channels; #endif if (!channels) avformat_find_stream_info( demuxer->ctx, NULL ); }
But I wonder if this is this the best way to do this. Maybe we should call `avformat_find_stream_info` unconditionally for some formats. It was avoided because it can take a bit more time and we want demuxer initialization to be fastest as possible (to match native and address some Unreal Engine potential race condition), but that's maybe only specific to MP4 as far as I know.
So something like: ```suggestion:-0+0 }
if (!(av_codec_get_tag(demuxer->ctx->iformat->codec_tag, AV_CODEC_ID_MPEG4))) { avformat_find_stream_info(demuxer->ctx, NULL); } ``` ?
Although it would probably make more sense to do this in `demuxer_create` after the call to `avformat_open_input` but before the call to `demuxer_create_streams`.
But I'm not that familiar with the FFmpeg API (which is why I narrowed the scope of the change), so I'm happy to take your lead on this.