Commit 41e49d45 authored by Derek Lesho's avatar Derek Lesho Committed by Alexandre Julliard

winegstreamer: Reformat type-setting functions to prevent the need for a…

winegstreamer: Reformat type-setting functions to prevent the need for a conditionally initialized variable. Signed-off-by: 's avatarDerek Lesho <dlesho@codeweavers.com> Signed-off-by: 's avatarZebediah Figura <z.figura12@gmail.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent aae9333c
......@@ -276,7 +276,9 @@ fail:
static HRESULT WINAPI audio_converter_SetInputType(IMFTransform *iface, DWORD id, IMFMediaType *type, DWORD flags)
{
GUID major_type, subtype;
GstCaps *input_caps;
DWORD unused;
HRESULT hr;
struct audio_converter *converter = impl_audio_converter_from_IMFTransform(iface);
......@@ -286,34 +288,46 @@ static HRESULT WINAPI audio_converter_SetInputType(IMFTransform *iface, DWORD id
if (id != 0)
return MF_E_INVALIDSTREAMNUMBER;
if (type)
if (!type)
{
GUID major_type, subtype;
DWORD unused;
if (FAILED(IMFMediaType_GetGUID(type, &MF_MT_MAJOR_TYPE, &major_type)))
return MF_E_INVALIDTYPE;
if (FAILED(IMFMediaType_GetGUID(type, &MF_MT_SUBTYPE, &subtype)))
return MF_E_INVALIDTYPE;
if (FAILED(IMFMediaType_GetUINT32(type, &MF_MT_AUDIO_SAMPLES_PER_SECOND, &unused)))
return MF_E_INVALIDTYPE;
if (FAILED(IMFMediaType_GetUINT32(type, &MF_MT_AUDIO_NUM_CHANNELS, &unused)))
return MF_E_INVALIDTYPE;
if (IsEqualGUID(&subtype, &MFAudioFormat_PCM) && FAILED(IMFMediaType_GetUINT32(type, &MF_MT_AUDIO_BITS_PER_SAMPLE, &unused)))
return MF_E_INVALIDTYPE;
if (!(IsEqualGUID(&major_type, &MFMediaType_Audio)))
return MF_E_INVALIDTYPE;
if (!IsEqualGUID(&subtype, &MFAudioFormat_PCM) && !IsEqualGUID(&subtype, &MFAudioFormat_Float))
return MF_E_INVALIDTYPE;
if (!(input_caps = caps_from_mf_media_type(type)))
return MF_E_INVALIDTYPE;
gst_caps_unref(input_caps);
if (flags & MFT_SET_TYPE_TEST_ONLY)
return S_OK;
EnterCriticalSection(&converter->cs);
if (converter->input_type)
{
IMFMediaType_Release(converter->input_type);
converter->input_type = NULL;
}
LeaveCriticalSection(&converter->cs);
return S_OK;
}
if (FAILED(IMFMediaType_GetGUID(type, &MF_MT_MAJOR_TYPE, &major_type)))
return MF_E_INVALIDTYPE;
if (FAILED(IMFMediaType_GetGUID(type, &MF_MT_SUBTYPE, &subtype)))
return MF_E_INVALIDTYPE;
if (FAILED(IMFMediaType_GetUINT32(type, &MF_MT_AUDIO_SAMPLES_PER_SECOND, &unused)))
return MF_E_INVALIDTYPE;
if (FAILED(IMFMediaType_GetUINT32(type, &MF_MT_AUDIO_NUM_CHANNELS, &unused)))
return MF_E_INVALIDTYPE;
if (IsEqualGUID(&subtype, &MFAudioFormat_PCM) && FAILED(IMFMediaType_GetUINT32(type, &MF_MT_AUDIO_BITS_PER_SAMPLE, &unused)))
return MF_E_INVALIDTYPE;
if (!(IsEqualGUID(&major_type, &MFMediaType_Audio)))
return MF_E_INVALIDTYPE;
if (!IsEqualGUID(&subtype, &MFAudioFormat_PCM) && !IsEqualGUID(&subtype, &MFAudioFormat_Float))
return MF_E_INVALIDTYPE;
if (!(input_caps = caps_from_mf_media_type(type)))
return MF_E_INVALIDTYPE;
gst_caps_unref(input_caps);
if (flags & MFT_SET_TYPE_TEST_ONLY)
return S_OK;
......@@ -321,21 +335,13 @@ static HRESULT WINAPI audio_converter_SetInputType(IMFTransform *iface, DWORD id
hr = S_OK;
if (type)
{
if (!converter->input_type)
hr = MFCreateMediaType(&converter->input_type);
if (!converter->input_type)
hr = MFCreateMediaType(&converter->input_type);
if (SUCCEEDED(hr))
hr = IMFMediaType_CopyAllItems(type, (IMFAttributes *) converter->input_type);
if (SUCCEEDED(hr))
hr = IMFMediaType_CopyAllItems(type, (IMFAttributes *) converter->input_type);
if (FAILED(hr))
{
IMFMediaType_Release(converter->input_type);
converter->input_type = NULL;
}
}
else if (converter->input_type)
if (FAILED(hr))
{
IMFMediaType_Release(converter->input_type);
converter->input_type = NULL;
......@@ -362,33 +368,46 @@ static HRESULT WINAPI audio_converter_SetOutputType(IMFTransform *iface, DWORD i
if (!converter->input_type)
return MF_E_TRANSFORM_TYPE_NOT_SET;
if (type)
if (!type)
{
/* validate the type */
if (FAILED(IMFMediaType_GetGUID(type, &MF_MT_MAJOR_TYPE, &major_type)))
return MF_E_INVALIDTYPE;
if (FAILED(IMFMediaType_GetGUID(type, &MF_MT_SUBTYPE, &subtype)))
return MF_E_INVALIDTYPE;
if (FAILED(IMFMediaType_GetUINT32(type, &MF_MT_AUDIO_NUM_CHANNELS, &unused)))
return MF_E_INVALIDTYPE;
if (IsEqualGUID(&subtype, &MFAudioFormat_PCM) && FAILED(IMFMediaType_GetUINT32(type, &MF_MT_AUDIO_BITS_PER_SAMPLE, &unused)))
return MF_E_INVALIDTYPE;
if (FAILED(IMFMediaType_GetUINT32(type, &MF_MT_AUDIO_SAMPLES_PER_SECOND, &unused)))
return MF_E_INVALIDTYPE;
if (flags & MFT_SET_TYPE_TEST_ONLY)
return S_OK;
if (!(IsEqualGUID(&major_type, &MFMediaType_Audio)))
return MF_E_INVALIDTYPE;
EnterCriticalSection(&converter->cs);
if (!IsEqualGUID(&subtype, &MFAudioFormat_PCM) && !IsEqualGUID(&subtype, &MFAudioFormat_Float))
return MF_E_INVALIDTYPE;
if (converter->output_type)
{
IMFMediaType_Release(converter->output_type);
converter->output_type = NULL;
}
if (!(output_caps = caps_from_mf_media_type(type)))
return MF_E_INVALIDTYPE;
LeaveCriticalSection(&converter->cs);
gst_caps_unref(output_caps);
return S_OK;
}
if (FAILED(IMFMediaType_GetGUID(type, &MF_MT_MAJOR_TYPE, &major_type)))
return MF_E_INVALIDTYPE;
if (FAILED(IMFMediaType_GetGUID(type, &MF_MT_SUBTYPE, &subtype)))
return MF_E_INVALIDTYPE;
if (FAILED(IMFMediaType_GetUINT32(type, &MF_MT_AUDIO_NUM_CHANNELS, &unused)))
return MF_E_INVALIDTYPE;
if (IsEqualGUID(&subtype, &MFAudioFormat_PCM) && FAILED(IMFMediaType_GetUINT32(type, &MF_MT_AUDIO_BITS_PER_SAMPLE, &unused)))
return MF_E_INVALIDTYPE;
if (FAILED(IMFMediaType_GetUINT32(type, &MF_MT_AUDIO_SAMPLES_PER_SECOND, &unused)))
return MF_E_INVALIDTYPE;
if (!(IsEqualGUID(&major_type, &MFMediaType_Audio)))
return MF_E_INVALIDTYPE;
if (!IsEqualGUID(&subtype, &MFAudioFormat_PCM) && !IsEqualGUID(&subtype, &MFAudioFormat_Float))
return MF_E_INVALIDTYPE;
if (!(output_caps = caps_from_mf_media_type(type)))
return MF_E_INVALIDTYPE;
gst_caps_unref(output_caps);
if (flags & MFT_SET_TYPE_TEST_ONLY)
return S_OK;
......@@ -396,21 +415,13 @@ static HRESULT WINAPI audio_converter_SetOutputType(IMFTransform *iface, DWORD i
hr = S_OK;
if (type)
{
if (!converter->output_type)
hr = MFCreateMediaType(&converter->output_type);
if (!converter->output_type)
hr = MFCreateMediaType(&converter->output_type);
if (SUCCEEDED(hr))
hr = IMFMediaType_CopyAllItems(type, (IMFAttributes *) converter->output_type);
if (SUCCEEDED(hr))
hr = IMFMediaType_CopyAllItems(type, (IMFAttributes *) converter->output_type);
if (FAILED(hr))
{
IMFMediaType_Release(converter->output_type);
converter->output_type = NULL;
}
}
else if (converter->output_type)
if (FAILED(hr))
{
IMFMediaType_Release(converter->output_type);
converter->output_type = NULL;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment