Commit 5dfe4776 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

mfreadwrite: Add a helper to get associated event object value.

parent 5b3fdc26
......@@ -122,6 +122,36 @@ static inline struct sink_writer *impl_from_IMFSinkWriter(IMFSinkWriter *iface)
return CONTAINING_RECORD(iface, struct sink_writer, IMFSinkWriter_iface);
}
static HRESULT media_event_get_object(IMFMediaEvent *event, REFIID riid, void **obj)
{
PROPVARIANT value;
HRESULT hr;
PropVariantInit(&value);
if (FAILED(hr = IMFMediaEvent_GetValue(event, &value)))
{
WARN("Failed to get event value, hr %#x.\n", hr);
return hr;
}
if (value.vt != VT_UNKNOWN || !value.u.punkVal)
{
WARN("Unexpected value type %d.\n", value.vt);
PropVariantClear(&value);
return E_UNEXPECTED;
}
hr = IUnknown_QueryInterface(value.u.punkVal, riid, obj);
PropVariantClear(&value);
if (FAILED(hr))
{
WARN("Unexpected object type.\n");
return hr;
}
return hr;
}
static HRESULT WINAPI source_reader_source_events_callback_QueryInterface(IMFAsyncCallback *iface,
REFIID riid, void **obj)
{
......@@ -162,30 +192,13 @@ static HRESULT source_reader_new_stream_handler(struct source_reader *reader, IM
{
IMFStreamDescriptor *sd;
IMFMediaStream *stream;
PROPVARIANT value;
unsigned int i;
DWORD id = 0;
HRESULT hr;
PropVariantInit(&value);
if (FAILED(hr = IMFMediaEvent_GetValue(event, &value)))
if (FAILED(hr = media_event_get_object(event, &IID_IMFMediaStream, (void **)&stream)))
{
WARN("Failed to get event value, hr %#x.\n", hr);
return hr;
}
if (value.vt != VT_UNKNOWN || !value.u.punkVal)
{
WARN("Unexpected value type %d.\n", value.vt);
PropVariantClear(&value);
return E_UNEXPECTED;
}
hr = IUnknown_QueryInterface(value.u.punkVal, &IID_IMFMediaStream, (void **)&stream);
PropVariantClear(&value);
if (FAILED(hr))
{
WARN("Unexpected object type.\n");
WARN("Failed to get stream object, hr %#x.\n", hr);
return hr;
}
......
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