diff --git a/dlls/mp3dmod/mp3dmod.c b/dlls/mp3dmod/mp3dmod.c index c89f32e9ed6..5e232f0443f 100644 --- a/dlls/mp3dmod/mp3dmod.c +++ b/dlls/mp3dmod/mp3dmod.c @@ -52,7 +52,7 @@ struct mp3_decoder mpg123_handle *mh; DMO_MEDIA_TYPE intype, outtype; - BOOL intype_set; + BOOL intype_set, outtype_set; IMediaBuffer *buffer; REFERENCE_TIME timestamp; @@ -262,6 +262,7 @@ static HRESULT WINAPI MediaObject_SetOutputType(IMediaObject *iface, DWORD index if (flags & DMO_SET_TYPEF_CLEAR) { MoFreeMediaType(&This->outtype); + This->outtype_set = FALSE; return S_OK; } @@ -287,6 +288,7 @@ static HRESULT WINAPI MediaObject_SetOutputType(IMediaObject *iface, DWORD index return DMO_E_TYPE_NOT_ACCEPTED; } MoCopyMediaType(&This->outtype, type); + This->outtype_set = TRUE; } return S_OK; @@ -306,11 +308,19 @@ static HRESULT WINAPI MediaObject_GetOutputCurrentType(IMediaObject *iface, DWOR return E_NOTIMPL; } -static HRESULT WINAPI MediaObject_GetInputSizeInfo(IMediaObject *iface, DWORD index, DWORD *size, DWORD *max_lookahead, DWORD *alignment) +static HRESULT WINAPI MediaObject_GetInputSizeInfo(IMediaObject *iface, + DWORD index, DWORD *size, DWORD *lookahead, DWORD *alignment) { - FIXME("(%p)->(%d, %p, %p, %p) stub!\n", iface, index, size, max_lookahead, alignment); + struct mp3_decoder *dmo = impl_from_IMediaObject(iface); - return E_NOTIMPL; + TRACE("iface %p, index %u, size %p, lookahead %p, alignment %p.\n", iface, index, size, lookahead, alignment); + + if (!dmo->intype_set || !dmo->outtype_set) + return DMO_E_TYPE_NOT_SET; + + *size = 0; + *alignment = 1; + return S_OK; } static HRESULT WINAPI MediaObject_GetOutputSizeInfo(IMediaObject *iface, DWORD index, DWORD *size, DWORD *alignment) diff --git a/dlls/mp3dmod/tests/mp3dmod.c b/dlls/mp3dmod/tests/mp3dmod.c index 1e410861eed..78471c42bcb 100644 --- a/dlls/mp3dmod/tests/mp3dmod.c +++ b/dlls/mp3dmod/tests/mp3dmod.c @@ -288,7 +288,36 @@ static void test_aggregation(void) static void test_stream_info(void) { - DWORD input_count, output_count, flags; + static const MPEGLAYER3WAVEFORMAT input_format = + { + .wfx.nChannels = 2, + .wfx.nSamplesPerSec = 48000, + }; + DMO_MEDIA_TYPE input_mt = + { + .majortype = MEDIATYPE_Audio, + .subtype = WMMEDIASUBTYPE_MP3, + .formattype = FORMAT_WaveFormatEx, + .cbFormat = sizeof(input_format), + .pbFormat = (BYTE *)&input_format, + }; + + static const WAVEFORMATEX output_format = + { + .nChannels = 1, + .nSamplesPerSec = 48000, + .nAvgBytesPerSec = 2 * 48000, + .nBlockAlign = 2, + .wBitsPerSample = 16, + }; + DMO_MEDIA_TYPE output_mt = + { + .formattype = FORMAT_WaveFormatEx, + .cbFormat = sizeof(output_format), + .pbFormat = (BYTE *)&output_format, + }; + + DWORD input_count, output_count, flags, size, lookahead, alignment; IMediaObject *dmo; HRESULT hr; @@ -311,6 +340,25 @@ static void test_stream_info(void) ok(hr == S_OK, "Got hr %#x.\n", hr); ok(!flags, "Got flags %#x.\n", flags); + hr = IMediaObject_GetInputSizeInfo(dmo, 0, &size, &lookahead, &alignment); + ok(hr == DMO_E_TYPE_NOT_SET, "Got hr %#x.\n", hr); + + hr = IMediaObject_SetInputType(dmo, 0, &input_mt, 0); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IMediaObject_GetInputSizeInfo(dmo, 0, &size, &lookahead, &alignment); + ok(hr == DMO_E_TYPE_NOT_SET, "Got hr %#x.\n", hr); + + hr = IMediaObject_SetOutputType(dmo, 0, &output_mt, 0); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + size = lookahead = alignment = 0xdeadbeef; + hr = IMediaObject_GetInputSizeInfo(dmo, 0, &size, &lookahead, &alignment); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(!size, "Got size %u.\n", size); + ok(lookahead == 0xdeadbeef, "Got lookahead %u.\n", lookahead); + ok(alignment == 1, "Got alignment %u.\n", alignment); + IMediaObject_Release(dmo); }