From 0c14a85d98cc512d2605d55f405d0b69bcca53ec Mon Sep 17 00:00:00 2001 From: Zebediah Figura Date: Fri, 11 May 2018 10:18:11 -0500 Subject: [PATCH] mp3dmod: Implement SetOutputType(). Signed-off-by: Zebediah Figura Signed-off-by: Alexandre Julliard --- dlls/mp3dmod/Makefile.in | 2 +- dlls/mp3dmod/mp3dmod.c | 44 ++++++++++++++++++++++++++++++++++++++-- include/mediaobj.idl | 5 +++++ 3 files changed, 48 insertions(+), 3 deletions(-) diff --git a/dlls/mp3dmod/Makefile.in b/dlls/mp3dmod/Makefile.in index 5bcef482dd5..0ac6d9680bc 100644 --- a/dlls/mp3dmod/Makefile.in +++ b/dlls/mp3dmod/Makefile.in @@ -1,5 +1,5 @@ MODULE = mp3dmod.dll -IMPORTS = dmoguids uuid wmcodecdspuuid +IMPORTS = dmoguids msdmo uuid wmcodecdspuuid EXTRAINCL = $(MPG123_CFLAGS) EXTRALIBS = $(MPG123_LIBS) diff --git a/dlls/mp3dmod/mp3dmod.c b/dlls/mp3dmod/mp3dmod.c index 9592280cb76..b9a4829a5e2 100644 --- a/dlls/mp3dmod/mp3dmod.c +++ b/dlls/mp3dmod/mp3dmod.c @@ -22,8 +22,11 @@ #include #include "windef.h" #include "winbase.h" +#include "wingdi.h" +#include "mmreg.h" #define COBJMACROS #include "objbase.h" +#include "dmo.h" #include "rpcproxy.h" #include "wmcodecdsp.h" #include "wine/debug.h" @@ -37,6 +40,7 @@ struct mp3_decoder { IMediaObject IMediaObject_iface; LONG ref; mpg123_handle *mh; + DMO_MEDIA_TYPE outtype; }; static inline struct mp3_decoder *impl_from_IMediaObject(IMediaObject *iface) @@ -132,9 +136,44 @@ static HRESULT WINAPI MediaObject_SetInputType(IMediaObject *iface, DWORD index, static HRESULT WINAPI MediaObject_SetOutputType(IMediaObject *iface, DWORD index, const DMO_MEDIA_TYPE *type, DWORD flags) { - FIXME("(%p)->(%d, %p, %#x) stub!\n", iface, index, type, flags); + struct mp3_decoder *This = impl_from_IMediaObject(iface); + WAVEFORMATEX *format; + long enc; + int err; - return E_NOTIMPL; + TRACE("(%p)->(%d, %p, %#x)\n", iface, index, type, flags); + + if (flags & DMO_SET_TYPEF_CLEAR) + { + MoFreeMediaType(&This->outtype); + return S_OK; + } + + format = (WAVEFORMATEX *)type->pbFormat; + + if (format->wBitsPerSample == 8) + enc = MPG123_ENC_UNSIGNED_8; + else if (format->wBitsPerSample == 16) + enc = MPG123_ENC_SIGNED_16; + else + { + ERR("Cannot decode to bit depth %u.\n", format->wBitsPerSample); + return DMO_E_TYPE_NOT_ACCEPTED; + } + + if (!(flags & DMO_SET_TYPEF_TEST_ONLY)) + { + err = mpg123_format(This->mh, format->nSamplesPerSec, format->nChannels, enc); + if (err != MPG123_OK) + { + ERR("Failed to set format: %u channels, %u samples/sec, %u bits/sample.\n", + format->nChannels, format->nSamplesPerSec, format->wBitsPerSample); + return DMO_E_TYPE_NOT_ACCEPTED; + } + MoCopyMediaType(&This->outtype, type); + } + + return S_OK; } static HRESULT WINAPI MediaObject_GetInputCurrentType(IMediaObject *iface, DWORD index, DMO_MEDIA_TYPE *type) @@ -277,6 +316,7 @@ static HRESULT create_mp3_decoder(REFIID iid, void **obj) mpg123_init(); This->mh = mpg123_new(NULL, &err); + mpg123_format_none(This->mh); return IMediaObject_QueryInterface(&This->IMediaObject_iface, iid, obj); } diff --git a/include/mediaobj.idl b/include/mediaobj.idl index 3c426f727d4..b6ae23634b0 100644 --- a/include/mediaobj.idl +++ b/include/mediaobj.idl @@ -102,6 +102,11 @@ enum _DMO_INPLACE_PROCESS_FLAGS { DMO_INPLACE_ZERO = 0x00000001 }; +enum _DMO_SET_TYPE_FLAGS { + DMO_SET_TYPEF_TEST_ONLY = 0x00000001, + DMO_SET_TYPEF_CLEAR = 0x00000002, +}; + /***************************************************************************** * IMediaObject interface */