This MR implements the following APIs in `mp3dmod`: - `GetInputCurrentType` - `GetOutputCurrentType`
It also adds checks to various APIs for an invalid stream and fixes a potential resource leak in `SetOutputType`.
This is in preparation for adding an `IMFTransform` interface to the MP3 decoder as detailed here:
https://learn.microsoft.com/en-us/windows/win32/medfound/windows-media-mp3-d...
-- v2: mp3dmod: Fix leak of previous outtype. mp3dmod: Implement GetOutputCurrentType. mp3dmod: Implement GetInputCurrentType.
From: Brendan McGrath bmcgrath@codeweavers.com
--- dlls/mp3dmod/tests/mp3dmod.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+)
diff --git a/dlls/mp3dmod/tests/mp3dmod.c b/dlls/mp3dmod/tests/mp3dmod.c index 7d213fcd18a..dd1d6171f55 100644 --- a/dlls/mp3dmod/tests/mp3dmod.c +++ b/dlls/mp3dmod/tests/mp3dmod.c @@ -171,7 +171,11 @@ static void test_convert(void) for (i = 0; i < 5; i++) memcpy(inbuf.data + 96 * i, mp3hdr, 4); inbuf.len = 96 * 5; + hr = IMediaObject_ProcessInput(dmo, 1, &inbuf.IMediaBuffer_iface, 0, 0, 0); + todo_wine + ok(hr == DMO_E_INVALIDSTREAMINDEX, "got %#lx\n", hr); hr = IMediaObject_ProcessInput(dmo, 0, &inbuf.IMediaBuffer_iface, 0, 0, 0); + todo_wine ok(hr == S_OK, "got %#lx\n", hr); ok(inbuf.refcount == 2, "Got refcount %ld.\n", inbuf.refcount);
@@ -425,6 +429,13 @@ static void test_stream_info(void) ok(hr == S_OK, "Got hr %#lx.\n", hr); ok(!flags, "Got flags %#lx.\n", flags);
+ hr = IMediaObject_GetInputSizeInfo(dmo, 1, &size, &lookahead, &alignment); + todo_wine + ok(hr == DMO_E_INVALIDSTREAMINDEX, "Got hr %#lx.\n", hr); + hr = IMediaObject_GetOutputSizeInfo(dmo, 1, &size, &alignment); + todo_wine + ok(hr == DMO_E_INVALIDSTREAMINDEX, "Got hr %#lx.\n", hr); + hr = IMediaObject_GetInputSizeInfo(dmo, 0, &size, &lookahead, &alignment); ok(hr == DMO_E_TYPE_NOT_SET, "Got hr %#lx.\n", hr); hr = IMediaObject_GetOutputSizeInfo(dmo, 0, &size, &alignment); @@ -524,6 +535,9 @@ static void test_media_types(void) ok(hr == S_OK, "Got hr %#lx.\n", hr);
memset(&mt, 0xcc, sizeof(DMO_MEDIA_TYPE)); + hr = IMediaObject_GetInputType(dmo, 1, 0, &mt); + todo_wine + ok(hr == DMO_E_INVALIDSTREAMINDEX, "Got hr %#lx.\n", hr); hr = IMediaObject_GetInputType(dmo, 0, 0, &mt); ok(hr == S_OK, "Got hr %#lx.\n", hr); ok(IsEqualGUID(&mt.majortype, &MEDIATYPE_Audio), "Got major type %s.\n", wine_dbgstr_guid(&mt.majortype)); @@ -541,9 +555,19 @@ static void test_media_types(void) ok(hr == DMO_E_NO_MORE_ITEMS, "Got hr %#lx.\n", hr);
memset(&mt, 0xcc, sizeof(DMO_MEDIA_TYPE)); + hr = IMediaObject_GetOutputType(dmo, 1, 0, &mt); + todo_wine + ok(hr == DMO_E_INVALIDSTREAMINDEX, "Got hr %#lx.\n", hr); hr = IMediaObject_GetOutputType(dmo, 0, 0, &mt); ok(hr == DMO_E_TYPE_NOT_SET, "Got hr %#lx.\n", hr);
+ hr = IMediaObject_SetOutputType(dmo, 0, &output_mt, DMO_SET_TYPEF_TEST_ONLY); + todo_wine + ok(hr == DMO_E_TYPE_NOT_SET, "Got hr %#lx.\n", hr); + + hr = IMediaObject_SetInputType(dmo, 1, &input_mt, DMO_SET_TYPEF_TEST_ONLY); + todo_wine + ok(hr == DMO_E_INVALIDSTREAMINDEX, "Got hr %#lx.\n", hr); hr = IMediaObject_SetInputType(dmo, 0, &input_mt, DMO_SET_TYPEF_TEST_ONLY); ok(hr == S_OK, "Got hr %#lx.\n", hr);
@@ -634,6 +658,10 @@ static void test_media_types(void) hr = IMediaObject_GetOutputType(dmo, 0, 2, &mt); ok(hr == DMO_E_NO_MORE_ITEMS, "Got hr %#lx.\n", hr);
+ hr = IMediaObject_SetOutputType(dmo, 1, &output_mt, DMO_SET_TYPEF_TEST_ONLY); + todo_wine + ok(hr == DMO_E_INVALIDSTREAMINDEX, "Got hr %#lx.\n", hr); + hr = IMediaObject_SetOutputType(dmo, 0, &output_mt, DMO_SET_TYPEF_TEST_ONLY); ok(hr == S_OK, "Got hr %#lx.\n", hr);
From: Brendan McGrath bmcgrath@codeweavers.com
--- dlls/mp3dmod/mp3dmod.c | 24 ++++++++++++++++++++++++ dlls/mp3dmod/tests/mp3dmod.c | 9 --------- 2 files changed, 24 insertions(+), 9 deletions(-)
diff --git a/dlls/mp3dmod/mp3dmod.c b/dlls/mp3dmod/mp3dmod.c index 842be5889da..830e94353e9 100644 --- a/dlls/mp3dmod/mp3dmod.c +++ b/dlls/mp3dmod/mp3dmod.c @@ -171,6 +171,9 @@ static HRESULT WINAPI MediaObject_GetInputType(IMediaObject *iface, DWORD index, { TRACE("iface %p, index %lu, type_index %lu, type %p.\n", iface, index, type_index, type);
+ if (index) + return DMO_E_INVALIDSTREAMINDEX; + if (type_index) return DMO_E_NO_MORE_ITEMS;
@@ -192,6 +195,9 @@ static HRESULT WINAPI MediaObject_GetOutputType(IMediaObject *iface, DWORD index
TRACE("iface %p, index %lu, type_index %lu, type %p.\n", iface, index, type_index, type);
+ if (index) + return DMO_E_INVALIDSTREAMINDEX; + if (!dmo->intype_set) return DMO_E_TYPE_NOT_SET;
@@ -225,6 +231,9 @@ static HRESULT WINAPI MediaObject_SetInputType(IMediaObject *iface, DWORD index,
TRACE("iface %p, index %lu, type %p, flags %#lx.\n", iface, index, type, flags);
+ if (index) + return DMO_E_INVALIDSTREAMINDEX; + if (flags & DMO_SET_TYPEF_CLEAR) { if (dmo->intype_set) @@ -258,6 +267,12 @@ static HRESULT WINAPI MediaObject_SetOutputType(IMediaObject *iface, DWORD index
TRACE("(%p)->(%ld, %p, %#lx)\n", iface, index, type, flags);
+ if (index) + return DMO_E_INVALIDSTREAMINDEX; + + if (!This->intype_set) + return DMO_E_TYPE_NOT_SET; + if (flags & DMO_SET_TYPEF_CLEAR) { MoFreeMediaType(&This->outtype); @@ -317,6 +332,9 @@ static HRESULT WINAPI MediaObject_GetInputSizeInfo(IMediaObject *iface,
TRACE("iface %p, index %lu, size %p, lookahead %p, alignment %p.\n", iface, index, size, lookahead, alignment);
+ if (index) + return DMO_E_INVALIDSTREAMINDEX; + if (!dmo->intype_set || !dmo->outtype_set) return DMO_E_TYPE_NOT_SET;
@@ -331,6 +349,9 @@ static HRESULT WINAPI MediaObject_GetOutputSizeInfo(IMediaObject *iface, DWORD i
TRACE("iface %p, index %lu, size %p, alignment %p.\n", iface, index, size, alignment);
+ if (index) + return DMO_E_INVALIDSTREAMINDEX; + if (!dmo->intype_set || !dmo->outtype_set) return DMO_E_TYPE_NOT_SET;
@@ -411,6 +432,9 @@ static HRESULT WINAPI MediaObject_ProcessInput(IMediaObject *iface, DWORD index, TRACE("(%p)->(%ld, %p, %#lx, %s, %s)\n", iface, index, buffer, flags, wine_dbgstr_longlong(timestamp), wine_dbgstr_longlong(timelength));
+ if (index) + return DMO_E_INVALIDSTREAMINDEX; + if (This->buffer) { ERR("Already have a buffer.\n"); diff --git a/dlls/mp3dmod/tests/mp3dmod.c b/dlls/mp3dmod/tests/mp3dmod.c index dd1d6171f55..ee59631f044 100644 --- a/dlls/mp3dmod/tests/mp3dmod.c +++ b/dlls/mp3dmod/tests/mp3dmod.c @@ -172,10 +172,8 @@ static void test_convert(void) memcpy(inbuf.data + 96 * i, mp3hdr, 4); inbuf.len = 96 * 5; hr = IMediaObject_ProcessInput(dmo, 1, &inbuf.IMediaBuffer_iface, 0, 0, 0); - todo_wine ok(hr == DMO_E_INVALIDSTREAMINDEX, "got %#lx\n", hr); hr = IMediaObject_ProcessInput(dmo, 0, &inbuf.IMediaBuffer_iface, 0, 0, 0); - todo_wine ok(hr == S_OK, "got %#lx\n", hr); ok(inbuf.refcount == 2, "Got refcount %ld.\n", inbuf.refcount);
@@ -430,10 +428,8 @@ static void test_stream_info(void) ok(!flags, "Got flags %#lx.\n", flags);
hr = IMediaObject_GetInputSizeInfo(dmo, 1, &size, &lookahead, &alignment); - todo_wine ok(hr == DMO_E_INVALIDSTREAMINDEX, "Got hr %#lx.\n", hr); hr = IMediaObject_GetOutputSizeInfo(dmo, 1, &size, &alignment); - todo_wine ok(hr == DMO_E_INVALIDSTREAMINDEX, "Got hr %#lx.\n", hr);
hr = IMediaObject_GetInputSizeInfo(dmo, 0, &size, &lookahead, &alignment); @@ -536,7 +532,6 @@ static void test_media_types(void)
memset(&mt, 0xcc, sizeof(DMO_MEDIA_TYPE)); hr = IMediaObject_GetInputType(dmo, 1, 0, &mt); - todo_wine ok(hr == DMO_E_INVALIDSTREAMINDEX, "Got hr %#lx.\n", hr); hr = IMediaObject_GetInputType(dmo, 0, 0, &mt); ok(hr == S_OK, "Got hr %#lx.\n", hr); @@ -556,17 +551,14 @@ static void test_media_types(void)
memset(&mt, 0xcc, sizeof(DMO_MEDIA_TYPE)); hr = IMediaObject_GetOutputType(dmo, 1, 0, &mt); - todo_wine ok(hr == DMO_E_INVALIDSTREAMINDEX, "Got hr %#lx.\n", hr); hr = IMediaObject_GetOutputType(dmo, 0, 0, &mt); ok(hr == DMO_E_TYPE_NOT_SET, "Got hr %#lx.\n", hr);
hr = IMediaObject_SetOutputType(dmo, 0, &output_mt, DMO_SET_TYPEF_TEST_ONLY); - todo_wine ok(hr == DMO_E_TYPE_NOT_SET, "Got hr %#lx.\n", hr);
hr = IMediaObject_SetInputType(dmo, 1, &input_mt, DMO_SET_TYPEF_TEST_ONLY); - todo_wine ok(hr == DMO_E_INVALIDSTREAMINDEX, "Got hr %#lx.\n", hr); hr = IMediaObject_SetInputType(dmo, 0, &input_mt, DMO_SET_TYPEF_TEST_ONLY); ok(hr == S_OK, "Got hr %#lx.\n", hr); @@ -659,7 +651,6 @@ static void test_media_types(void) ok(hr == DMO_E_NO_MORE_ITEMS, "Got hr %#lx.\n", hr);
hr = IMediaObject_SetOutputType(dmo, 1, &output_mt, DMO_SET_TYPEF_TEST_ONLY); - todo_wine ok(hr == DMO_E_INVALIDSTREAMINDEX, "Got hr %#lx.\n", hr);
hr = IMediaObject_SetOutputType(dmo, 0, &output_mt, DMO_SET_TYPEF_TEST_ONLY);
From: Brendan McGrath brendan@redmandi.com
--- dlls/mp3dmod/tests/mp3dmod.c | 75 ++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+)
diff --git a/dlls/mp3dmod/tests/mp3dmod.c b/dlls/mp3dmod/tests/mp3dmod.c index ee59631f044..f7ecf6943bc 100644 --- a/dlls/mp3dmod/tests/mp3dmod.c +++ b/dlls/mp3dmod/tests/mp3dmod.c @@ -40,6 +40,49 @@ static REFERENCE_TIME samplelen(DWORD samples, int rate) return (REFERENCE_TIME) 10000000 * samples / rate; }
+#define check_member_(line, val, exp, fmt, member) \ + ok_ (__FILE__, line)((val).member == (exp).member, "Got " #member " " fmt ", expected " fmt ".\n", (val).member, (exp).member) +#define check_member(val, exp, fmt, member) check_member_(__LINE__, val, exp, fmt, member) + +#define check_wave_format(a, b) check_wave_format_(__LINE__, a, b) +static void check_wave_format_(int line, WAVEFORMATEX *info, const WAVEFORMATEX *expected) +{ + check_member_(line, *info, *expected, "%#x", wFormatTag); + check_member_(line, *info, *expected, "%u", nChannels); + check_member_(line, *info, *expected, "%lu", nSamplesPerSec); + check_member_(line, *info, *expected, "%lu", nAvgBytesPerSec); + check_member_(line, *info, *expected, "%u", nBlockAlign); + check_member_(line, *info, *expected, "%u", wBitsPerSample); + check_member_(line, *info, *expected, "%u", cbSize); +} + +#define check_dmo_media_type(a, b) check_dmo_media_type_(__LINE__, a, b) +static void check_dmo_media_type_(int line, DMO_MEDIA_TYPE *media_type, const DMO_MEDIA_TYPE *expected) +{ + ok_(__FILE__, line)(IsEqualGUID(&media_type->majortype, &expected->majortype), + "Got unexpected majortype %s, expected %s.\n", + debugstr_guid(&media_type->majortype), debugstr_guid(&expected->majortype)); + ok_(__FILE__, line)(IsEqualGUID(&media_type->subtype, &expected->subtype), + "Got unexpected subtype %s, expected %s.\n", + debugstr_guid(&media_type->subtype), debugstr_guid(&expected->subtype)); + ok_(__FILE__, line)(IsEqualGUID(&media_type->formattype, &expected->formattype), + "Got unexpected formattype %s.\n", + debugstr_guid(&media_type->formattype)); + ok_(__FILE__, line)(media_type->pUnk == NULL, "Got unexpected pUnk %p.\n", media_type->pUnk); + check_member_(line, *media_type, *expected, "%lu", cbFormat); + + if (expected->pbFormat) + { + ok_(__FILE__, line)(!!media_type->pbFormat, "Got NULL pbFormat.\n"); + if (!media_type->pbFormat) + return; + + if (IsEqualGUID(&media_type->formattype, &FORMAT_WaveFormatEx) + && IsEqualGUID(&expected->formattype, &FORMAT_WaveFormatEx)) + check_wave_format((WAVEFORMATEX *)media_type->pbFormat, (WAVEFORMATEX *)expected->pbFormat); + } +} + struct test_buffer { IMediaBuffer IMediaBuffer_iface; @@ -558,11 +601,23 @@ static void test_media_types(void) hr = IMediaObject_SetOutputType(dmo, 0, &output_mt, DMO_SET_TYPEF_TEST_ONLY); ok(hr == DMO_E_TYPE_NOT_SET, "Got hr %#lx.\n", hr);
+ hr = IMediaObject_GetInputCurrentType(dmo, 1, &mt); + todo_wine + ok(hr == DMO_E_INVALIDSTREAMINDEX, "Got hr %#lx.\n", hr); + + hr = IMediaObject_GetInputCurrentType(dmo, 0, &mt); + todo_wine + ok(hr == DMO_E_TYPE_NOT_SET, "Got hr %#lx.\n", hr); + hr = IMediaObject_SetInputType(dmo, 1, &input_mt, DMO_SET_TYPEF_TEST_ONLY); ok(hr == DMO_E_INVALIDSTREAMINDEX, "Got hr %#lx.\n", hr); hr = IMediaObject_SetInputType(dmo, 0, &input_mt, DMO_SET_TYPEF_TEST_ONLY); ok(hr == S_OK, "Got hr %#lx.\n", hr);
+ hr = IMediaObject_GetInputCurrentType(dmo, 0, &mt); + todo_wine + ok(hr == DMO_E_TYPE_NOT_SET, "Got hr %#lx.\n", hr); + input_mt.majortype = GUID_NULL; hr = IMediaObject_SetInputType(dmo, 0, &input_mt, DMO_SET_TYPEF_TEST_ONLY); ok(hr == DMO_E_TYPE_NOT_ACCEPTED, "Got hr %#lx.\n", hr); @@ -590,6 +645,16 @@ static void test_media_types(void) hr = IMediaObject_SetInputType(dmo, 0, &input_mt, 0); ok(hr == S_OK, "Got hr %#lx.\n", hr);
+ hr = IMediaObject_GetInputCurrentType(dmo, 0, &mt); + todo_wine + ok(hr == S_OK, "Got hr %#lx.\n", hr); + + if (hr == S_OK) + { + check_dmo_media_type(&mt, &input_mt); + MoFreeMediaType(&mt); + } + for (i = 0; i < 4; ++i) { memset(&mt, 0xcc, sizeof(DMO_MEDIA_TYPE)); @@ -622,6 +687,16 @@ static void test_media_types(void) hr = IMediaObject_SetInputType(dmo, 0, &input_mt, 0); ok(hr == S_OK, "Got hr %#lx.\n", hr);
+ hr = IMediaObject_GetInputCurrentType(dmo, 0, &mt); + todo_wine + ok(hr == S_OK, "Got hr %#lx.\n", hr); + + if (hr == S_OK) + { + check_dmo_media_type(&mt, &input_mt); + MoFreeMediaType(&mt); + } + for (i = 0; i < 2; ++i) { memset(&mt, 0xcc, sizeof(DMO_MEDIA_TYPE));
From: Brendan McGrath brendan@redmandi.com
--- dlls/mp3dmod/tests/mp3dmod.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)
diff --git a/dlls/mp3dmod/tests/mp3dmod.c b/dlls/mp3dmod/tests/mp3dmod.c index f7ecf6943bc..8b82e9509af 100644 --- a/dlls/mp3dmod/tests/mp3dmod.c +++ b/dlls/mp3dmod/tests/mp3dmod.c @@ -728,9 +728,21 @@ static void test_media_types(void) hr = IMediaObject_SetOutputType(dmo, 1, &output_mt, DMO_SET_TYPEF_TEST_ONLY); ok(hr == DMO_E_INVALIDSTREAMINDEX, "Got hr %#lx.\n", hr);
+ hr = IMediaObject_GetOutputCurrentType(dmo, 1, &mt); + todo_wine + ok(hr == DMO_E_INVALIDSTREAMINDEX, "Got hr %#lx.\n", hr); + + hr = IMediaObject_GetOutputCurrentType(dmo, 0, &mt); + todo_wine + ok(hr == DMO_E_TYPE_NOT_SET, "Got hr %#lx.\n", hr); + hr = IMediaObject_SetOutputType(dmo, 0, &output_mt, DMO_SET_TYPEF_TEST_ONLY); ok(hr == S_OK, "Got hr %#lx.\n", hr);
+ hr = IMediaObject_GetOutputCurrentType(dmo, 0, &mt); + todo_wine + ok(hr == DMO_E_TYPE_NOT_SET, "Got hr %#lx.\n", hr); + output_mt.formattype = GUID_NULL; hr = IMediaObject_SetOutputType(dmo, 0, &output_mt, DMO_SET_TYPEF_TEST_ONLY); ok(hr == DMO_E_TYPE_NOT_ACCEPTED, "Got hr %#lx.\n", hr); @@ -739,6 +751,19 @@ static void test_media_types(void) ok(hr == DMO_E_TYPE_NOT_ACCEPTED, "Got hr %#lx.\n", hr); output_mt.formattype = FORMAT_WaveFormatEx;
+ hr = IMediaObject_SetOutputType(dmo, 0, &output_mt, 0); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + + hr = IMediaObject_GetOutputCurrentType(dmo, 0, &mt); + todo_wine + ok(hr == S_OK, "Got hr %#lx.\n", hr); + + if (hr == S_OK) + { + check_dmo_media_type(&mt, &output_mt); + MoFreeMediaType(&mt); + } + IMediaObject_Release(dmo); }
From: Brendan McGrath brendan@redmandi.com
--- dlls/mp3dmod/mp3dmod.c | 13 +++++++++++-- dlls/mp3dmod/tests/mp3dmod.c | 19 ++++--------------- 2 files changed, 15 insertions(+), 17 deletions(-)
diff --git a/dlls/mp3dmod/mp3dmod.c b/dlls/mp3dmod/mp3dmod.c index 830e94353e9..4cdb92ce0b0 100644 --- a/dlls/mp3dmod/mp3dmod.c +++ b/dlls/mp3dmod/mp3dmod.c @@ -313,9 +313,18 @@ static HRESULT WINAPI MediaObject_SetOutputType(IMediaObject *iface, DWORD index
static HRESULT WINAPI MediaObject_GetInputCurrentType(IMediaObject *iface, DWORD index, DMO_MEDIA_TYPE *type) { - FIXME("(%p)->(%ld, %p) stub!\n", iface, index, type); + struct mp3_decoder *dmo = impl_from_IMediaObject(iface); + TRACE("(%p)->(%ld, %p)\n", iface, index, type);
- return E_NOTIMPL; + if (index) + return DMO_E_INVALIDSTREAMINDEX; + + if (!dmo->intype_set) + return DMO_E_TYPE_NOT_SET; + + MoCopyMediaType(type, &dmo->intype); + + return S_OK; }
static HRESULT WINAPI MediaObject_GetOutputCurrentType(IMediaObject *iface, DWORD index, DMO_MEDIA_TYPE *type) diff --git a/dlls/mp3dmod/tests/mp3dmod.c b/dlls/mp3dmod/tests/mp3dmod.c index 8b82e9509af..75ad52c4f21 100644 --- a/dlls/mp3dmod/tests/mp3dmod.c +++ b/dlls/mp3dmod/tests/mp3dmod.c @@ -602,11 +602,9 @@ static void test_media_types(void) ok(hr == DMO_E_TYPE_NOT_SET, "Got hr %#lx.\n", hr);
hr = IMediaObject_GetInputCurrentType(dmo, 1, &mt); - todo_wine ok(hr == DMO_E_INVALIDSTREAMINDEX, "Got hr %#lx.\n", hr);
hr = IMediaObject_GetInputCurrentType(dmo, 0, &mt); - todo_wine ok(hr == DMO_E_TYPE_NOT_SET, "Got hr %#lx.\n", hr);
hr = IMediaObject_SetInputType(dmo, 1, &input_mt, DMO_SET_TYPEF_TEST_ONLY); @@ -615,7 +613,6 @@ static void test_media_types(void) ok(hr == S_OK, "Got hr %#lx.\n", hr);
hr = IMediaObject_GetInputCurrentType(dmo, 0, &mt); - todo_wine ok(hr == DMO_E_TYPE_NOT_SET, "Got hr %#lx.\n", hr);
input_mt.majortype = GUID_NULL; @@ -646,14 +643,10 @@ static void test_media_types(void) ok(hr == S_OK, "Got hr %#lx.\n", hr);
hr = IMediaObject_GetInputCurrentType(dmo, 0, &mt); - todo_wine ok(hr == S_OK, "Got hr %#lx.\n", hr);
- if (hr == S_OK) - { - check_dmo_media_type(&mt, &input_mt); - MoFreeMediaType(&mt); - } + check_dmo_media_type(&mt, &input_mt); + MoFreeMediaType(&mt);
for (i = 0; i < 4; ++i) { @@ -688,14 +681,10 @@ static void test_media_types(void) ok(hr == S_OK, "Got hr %#lx.\n", hr);
hr = IMediaObject_GetInputCurrentType(dmo, 0, &mt); - todo_wine ok(hr == S_OK, "Got hr %#lx.\n", hr);
- if (hr == S_OK) - { - check_dmo_media_type(&mt, &input_mt); - MoFreeMediaType(&mt); - } + check_dmo_media_type(&mt, &input_mt); + MoFreeMediaType(&mt);
for (i = 0; i < 2; ++i) {
From: Brendan McGrath brendan@redmandi.com
--- dlls/mp3dmod/mp3dmod.c | 13 +++++++++++-- dlls/mp3dmod/tests/mp3dmod.c | 11 ++--------- 2 files changed, 13 insertions(+), 11 deletions(-)
diff --git a/dlls/mp3dmod/mp3dmod.c b/dlls/mp3dmod/mp3dmod.c index 4cdb92ce0b0..93a2a1a4d8f 100644 --- a/dlls/mp3dmod/mp3dmod.c +++ b/dlls/mp3dmod/mp3dmod.c @@ -329,9 +329,18 @@ static HRESULT WINAPI MediaObject_GetInputCurrentType(IMediaObject *iface, DWORD
static HRESULT WINAPI MediaObject_GetOutputCurrentType(IMediaObject *iface, DWORD index, DMO_MEDIA_TYPE *type) { - FIXME("(%p)->(%ld, %p) stub!\n", iface, index, type); + struct mp3_decoder *dmo = impl_from_IMediaObject(iface); + TRACE("(%p)->(%ld, %p)\n", iface, index, type);
- return E_NOTIMPL; + if (index) + return DMO_E_INVALIDSTREAMINDEX; + + if (!dmo->outtype_set) + return DMO_E_TYPE_NOT_SET; + + MoCopyMediaType(type, &dmo->outtype); + + return S_OK; }
static HRESULT WINAPI MediaObject_GetInputSizeInfo(IMediaObject *iface, diff --git a/dlls/mp3dmod/tests/mp3dmod.c b/dlls/mp3dmod/tests/mp3dmod.c index 75ad52c4f21..107533e6316 100644 --- a/dlls/mp3dmod/tests/mp3dmod.c +++ b/dlls/mp3dmod/tests/mp3dmod.c @@ -718,18 +718,15 @@ static void test_media_types(void) ok(hr == DMO_E_INVALIDSTREAMINDEX, "Got hr %#lx.\n", hr);
hr = IMediaObject_GetOutputCurrentType(dmo, 1, &mt); - todo_wine ok(hr == DMO_E_INVALIDSTREAMINDEX, "Got hr %#lx.\n", hr);
hr = IMediaObject_GetOutputCurrentType(dmo, 0, &mt); - todo_wine ok(hr == DMO_E_TYPE_NOT_SET, "Got hr %#lx.\n", hr);
hr = IMediaObject_SetOutputType(dmo, 0, &output_mt, DMO_SET_TYPEF_TEST_ONLY); ok(hr == S_OK, "Got hr %#lx.\n", hr);
hr = IMediaObject_GetOutputCurrentType(dmo, 0, &mt); - todo_wine ok(hr == DMO_E_TYPE_NOT_SET, "Got hr %#lx.\n", hr);
output_mt.formattype = GUID_NULL; @@ -744,14 +741,10 @@ static void test_media_types(void) ok(hr == S_OK, "Got hr %#lx.\n", hr);
hr = IMediaObject_GetOutputCurrentType(dmo, 0, &mt); - todo_wine ok(hr == S_OK, "Got hr %#lx.\n", hr);
- if (hr == S_OK) - { - check_dmo_media_type(&mt, &output_mt); - MoFreeMediaType(&mt); - } + check_dmo_media_type(&mt, &output_mt); + MoFreeMediaType(&mt);
IMediaObject_Release(dmo); }
From: Brendan McGrath brendan@redmandi.com
--- dlls/mp3dmod/mp3dmod.c | 2 ++ 1 file changed, 2 insertions(+)
diff --git a/dlls/mp3dmod/mp3dmod.c b/dlls/mp3dmod/mp3dmod.c index 93a2a1a4d8f..55a5b2f5933 100644 --- a/dlls/mp3dmod/mp3dmod.c +++ b/dlls/mp3dmod/mp3dmod.c @@ -304,6 +304,8 @@ static HRESULT WINAPI MediaObject_SetOutputType(IMediaObject *iface, DWORD index format->nChannels, format->nSamplesPerSec, format->wBitsPerSample); return DMO_E_TYPE_NOT_ACCEPTED; } + if (This->outtype_set) + MoFreeMediaType(&This->outtype); MoCopyMediaType(&This->outtype, type); This->outtype_set = TRUE; }
On Mon Feb 24 20:10:47 2025 +0000, Brendan McGrath wrote:
changed this line in [version 2 of the diff](/wine/wine/-/merge_requests/7409/diffs?diff_id=160040&start_sha=af1c4a76840ebe2bec0fcf03da89d7fc275c1684#8ed0f792e0cfb947b84582424f7eab968ada64c9_319_319)
Oops. Thank-you. Fixed.