[PATCH 3/3] mfplat: Implement GetAudioFormat method for IMFAudioMediaType interface.
Connor McAdams
cmcadams at codeweavers.com
Tue Apr 20 20:58:44 CDT 2021
Signed-off-by: Connor McAdams <cmcadams at codeweavers.com>
---
dlls/mfplat/mediatype.c | 27 ++++++++++++++++++++++++---
1 file changed, 24 insertions(+), 3 deletions(-)
diff --git a/dlls/mfplat/mediatype.c b/dlls/mfplat/mediatype.c
index 4904dbb566f..36747cae5ca 100644
--- a/dlls/mfplat/mediatype.c
+++ b/dlls/mfplat/mediatype.c
@@ -41,6 +41,7 @@ struct media_type
IMFVideoMediaType IMFVideoMediaType_iface;
IMFAudioMediaType IMFAudioMediaType_iface;
MFVIDEOFORMAT *video_format;
+ WAVEFORMATEX *audio_format;
};
struct stream_desc
@@ -1048,7 +1049,18 @@ static ULONG WINAPI audio_mediatype_AddRef(IMFAudioMediaType *iface)
static ULONG WINAPI audio_mediatype_Release(IMFAudioMediaType *iface)
{
struct media_type *media_type = impl_from_IMFAudioMediaType(iface);
- return IMFMediaType_Release(&media_type->IMFMediaType_iface);
+ ULONG refcount = InterlockedDecrement(&media_type->attributes.ref);
+
+ TRACE("%p, refcount %u.\n", iface, refcount);
+
+ if (!refcount)
+ {
+ clear_attributes_object(&media_type->attributes);
+ CoTaskMemFree(media_type->audio_format);
+ heap_free(media_type);
+ }
+
+ return refcount;
}
static HRESULT WINAPI audio_mediatype_GetItem(IMFAudioMediaType *iface, REFGUID key, PROPVARIANT *value)
@@ -1368,9 +1380,18 @@ static HRESULT WINAPI audio_mediatype_FreeRepresentation(IMFAudioMediaType *ifac
static const WAVEFORMATEX * WINAPI audio_mediatype_GetAudioFormat(IMFAudioMediaType *iface)
{
- FIXME("%p.\n", iface);
+ struct media_type *media_type = impl_from_IMFAudioMediaType(iface);
+ unsigned int size;
+ HRESULT hr;
+
+ TRACE("%p.\n", iface);
+
+ CoTaskMemFree(media_type->audio_format);
+ if (FAILED(hr = MFCreateWaveFormatExFromMFMediaType((IMFMediaType *)iface, &media_type->audio_format, &size,
+ MFWaveFormatExConvertFlag_Normal)))
+ WARN("Failed to create wave format description, hr %#x.\n", hr);
- return NULL;
+ return media_type->audio_format;
}
static const IMFAudioMediaTypeVtbl audiomediatypevtbl =
--
2.25.1
More information about the wine-devel
mailing list