From: Santino Mazza smazza@codeweavers.com
--- dlls/amstream/ddrawstream.c | 59 ++++++++++++++++++---------------- dlls/amstream/tests/amstream.c | 8 ++--- 2 files changed, 36 insertions(+), 31 deletions(-)
diff --git a/dlls/amstream/ddrawstream.c b/dlls/amstream/ddrawstream.c index 47b856781e9..177de5a42f7 100644 --- a/dlls/amstream/ddrawstream.c +++ b/dlls/amstream/ddrawstream.c @@ -55,7 +55,7 @@ struct ddraw_stream IFilterGraph *graph;
IPin *peer; - IMemAllocator *allocator; + IMemAllocator *private_allocator; AM_MEDIA_TYPE mt; struct format format; FILTER_STATE state; @@ -235,6 +235,7 @@ static ULONG WINAPI ddraw_IAMMediaStream_Release(IAMMediaStream *iface) DeleteCriticalSection(&stream->cs); if (stream->ddraw) IDirectDraw_Release(stream->ddraw); + IMemAllocator_Release(stream->private_allocator); free(stream); }
@@ -1306,40 +1307,46 @@ static ULONG WINAPI ddraw_mem_allocator_Release(IMemAllocator *iface)
static HRESULT WINAPI ddraw_mem_allocator_SetProperties(IMemAllocator *iface, ALLOCATOR_PROPERTIES *request, ALLOCATOR_PROPERTIES *actual) { - FIXME("iface %p request %p actual %p stub!\n", iface, request, actual); - return E_NOTIMPL; + struct ddraw_stream *stream = impl_from_IMemAllocator(iface); + + return IMemAllocator_SetProperties(stream->private_allocator, request, actual); }
static HRESULT WINAPI ddraw_mem_allocator_GetProperties(IMemAllocator *iface,ALLOCATOR_PROPERTIES *props) { - FIXME("iface %p props %p stub!\n", iface, props); - return E_NOTIMPL; + struct ddraw_stream *stream = impl_from_IMemAllocator(iface); + + return IMemAllocator_GetProperties(stream->private_allocator, props); }
static HRESULT WINAPI ddraw_mem_allocator_Commit(IMemAllocator *iface) { - FIXME("iface %p stub!\n", iface); - return E_NOTIMPL; + struct ddraw_stream *stream = impl_from_IMemAllocator(iface); + + return IMemAllocator_Commit(stream->private_allocator); }
static HRESULT WINAPI ddraw_mem_allocator_Decommit(IMemAllocator *iface) { - FIXME("iface %p stub!\n", iface); - return E_NOTIMPL; + struct ddraw_stream *stream = impl_from_IMemAllocator(iface); + + return IMemAllocator_Decommit(stream->private_allocator); }
static HRESULT WINAPI ddraw_mem_allocator_GetBuffer(IMemAllocator *iface, IMediaSample **buf, REFERENCE_TIME *start_time, REFERENCE_TIME *end_time, DWORD flags) { - FIXME("iface %p buf %p start_time %p end_time %p flags %#lx stub!\n", iface, buf, start_time, end_time, flags); - return E_NOTIMPL; + struct ddraw_stream *stream = impl_from_IMemAllocator(iface); + + return IMemAllocator_GetBuffer(stream->private_allocator, buf, start_time, end_time, flags); }
static HRESULT WINAPI ddraw_mem_allocator_ReleaseBuffer(IMemAllocator *iface,IMediaSample *buf) { - FIXME("iface %p buf %p stub!\n", iface, buf); - return E_NOTIMPL; + struct ddraw_stream *stream = impl_from_IMemAllocator(iface); + + return IMemAllocator_ReleaseBuffer(stream->private_allocator, buf); }
static const IMemAllocatorVtbl ddraw_mem_allocator_vtbl = @@ -1384,14 +1391,8 @@ static HRESULT WINAPI ddraw_meminput_GetAllocator(IMemInputPin *iface, IMemAlloc
TRACE("stream %p, allocator %p.\n", stream, allocator);
- if (stream->allocator) - { - IMemAllocator_AddRef(*allocator = stream->allocator); - return S_OK; - } - - *allocator = NULL; - return VFW_E_NO_ALLOCATOR; + IMemAllocator_AddRef(*allocator = &stream->IMemAllocator_iface); + return S_OK; }
static HRESULT WINAPI ddraw_meminput_NotifyAllocator(IMemInputPin *iface, IMemAllocator *allocator, BOOL readonly) @@ -1403,12 +1404,6 @@ static HRESULT WINAPI ddraw_meminput_NotifyAllocator(IMemInputPin *iface, IMemAl if (!allocator) return E_POINTER;
- if (allocator) - IMemAllocator_AddRef(allocator); - if (stream->allocator) - IMemAllocator_Release(stream->allocator); - stream->allocator = allocator; - return S_OK; }
@@ -1554,6 +1549,7 @@ static const IMemInputPinVtbl ddraw_meminput_vtbl = HRESULT ddraw_stream_create(IUnknown *outer, void **out) { struct ddraw_stream *object; + HRESULT hr;
if (outer) return CLASS_E_NOAGGREGATION; @@ -1564,6 +1560,7 @@ HRESULT ddraw_stream_create(IUnknown *outer, void **out) object->IAMMediaStream_iface.lpVtbl = &ddraw_IAMMediaStream_vtbl; object->IDirectDrawMediaStream_iface.lpVtbl = &ddraw_IDirectDrawMediaStream_Vtbl; object->IMemInputPin_iface.lpVtbl = &ddraw_meminput_vtbl; + object->IMemAllocator_iface.lpVtbl = &ddraw_mem_allocator_vtbl; object->IPin_iface.lpVtbl = &ddraw_sink_vtbl; object->IMemAllocator_iface.lpVtbl = &ddraw_mem_allocator_vtbl; object->ref = 1; @@ -1571,6 +1568,14 @@ HRESULT ddraw_stream_create(IUnknown *outer, void **out) object->format.width = 100; object->format.height = 100;
+ hr = CoCreateInstance(&CLSID_MemoryAllocator, NULL, CLSCTX_INPROC_SERVER, + &IID_IMemAllocator, (void **)&object->private_allocator); + if (!SUCCEEDED(hr)) + { + free(object); + return hr; + }; + InitializeCriticalSection(&object->cs); InitializeConditionVariable(&object->update_queued_cv); list_init(&object->update_queue); diff --git a/dlls/amstream/tests/amstream.c b/dlls/amstream/tests/amstream.c index 968cca59ead..f78d06eb0de 100644 --- a/dlls/amstream/tests/amstream.c +++ b/dlls/amstream/tests/amstream.c @@ -8526,8 +8526,8 @@ static void test_ddrawstream_mem_allocator(void) {
mem_allocator = NULL; hr = IMemInputPin_GetAllocator(mem_input, &mem_allocator); - todo_wine ok(hr == S_OK, "Got hr %#lx.\n", hr); - todo_wine ok(mem_allocator == ddraw_allocator, "Expected GetAllocator to return ddraw allocator.\n"); + ok(hr == S_OK, "Got hr %#lx.\n", hr); + ok(mem_allocator == ddraw_allocator, "Expected GetAllocator to return ddraw allocator.\n");
if (mem_allocator) { @@ -8552,8 +8552,8 @@ static void test_ddrawstream_mem_allocator(void) { mem_allocator = NULL; hr = IMemInputPin_GetAllocator(mem_input, &mem_allocator); ok(hr == S_OK, "Got hr %#lx.\n", hr); - todo_wine ok(mem_allocator == ddraw_allocator, "Expected GetAllocator to return ddraw allocator.\n"); - todo_wine check_interface(mem_allocator, &IID_IDirectDrawMediaStream, TRUE); + ok(mem_allocator == ddraw_allocator, "Expected GetAllocator to return ddraw allocator.\n"); + check_interface(mem_allocator, &IID_IDirectDrawMediaStream, TRUE);
IMemInputPin_Release(mem_input);