[PATCH] winegstreamer: Ensure that the source reports both PCM and floating point audio formats.

Nikolay Sivov nsivov at codeweavers.com
Wed May 12 03:15:15 CDT 2021



On 5/7/21 7:02 PM, Giovanni Mascellani wrote:
> +    else if (format.major_type == WG_MAJOR_TYPE_AUDIO)
> +    {
> +        /* Expose at least one PCM and one floating point type for the
> +           consumer to pick from. */
> +        stream_types = malloc( sizeof(IMFMediaType *) * 2 );
> +
> +        stream_types[0] = mf_media_type_from_wg_format(&format);
> +        if (stream_types[0])
> +        {
> +            stream_types[1] = mf_media_type_from_wg_format(&format);
> +            if (stream_types[1])
> +            {
> +                GUID base_subtype;
> +                IMFMediaType_GetGUID(stream_types[1], &MF_MT_SUBTYPE, &base_subtype);
> +                if (IsEqualGUID(&base_subtype, &MFAudioFormat_Float))
> +                {
> +                    IMFMediaType_SetGUID(stream_types[1], &MF_MT_SUBTYPE, &MFAudioFormat_PCM);
> +                    IMFMediaType_SetUINT32(stream_types[1], &MF_MT_AUDIO_BITS_PER_SAMPLE, 16);
> +                }
> +                else
> +                {
> +                    IMFMediaType_SetGUID(stream_types[1], &MF_MT_SUBTYPE, &MFAudioFormat_Float);
> +                    IMFMediaType_SetUINT32(stream_types[1], &MF_MT_AUDIO_BITS_PER_SAMPLE, 32);
> +                }
> +                type_count = 2;
> +            }
> +        }
> +    }
I was thinking this could be done similar to video section, you can have
a list of WG types to add, and let mf_media_type_from_wg_format() do the
job.

{
   S16LE,
   F32LE,
} types;

for ()
{
    if (types[i] == base_type.audio.format) continue;
    format.audio.format = types[i];
    stream_types[type_count++] = mf_media_type_from_wg_format(&format);
}

That seems shorter and reuses as much as possible from conversion helpers.

>      hr = IMFSourceReader_GetNativeMediaType(reader, MF_SOURCE_READER_FIRST_AUDIO_STREAM, 1, &mediatype);
> +todo_wine
>      ok(hr == MF_E_NO_MORE_TYPES, "Unexpected hr %#x.\n", hr);
If we're going to add more formats this will never succeed, so either
use larger index that will never work in practice, like 100, or remove
the test.



More information about the wine-devel mailing list