From: Santino Mazza smazza@codeweavers.com
--- dlls/amstream/ddrawstream.c | 19 ++++++++++++++++++- dlls/amstream/tests/amstream.c | 14 +++++++------- 2 files changed, 25 insertions(+), 8 deletions(-)
diff --git a/dlls/amstream/ddrawstream.c b/dlls/amstream/ddrawstream.c index 80a5bd5db14..c7eba9b4892 100644 --- a/dlls/amstream/ddrawstream.c +++ b/dlls/amstream/ddrawstream.c @@ -592,6 +592,7 @@ static HRESULT WINAPI ddraw_IDirectDrawMediaStream_SetFormat(IDirectDrawMediaStr const DDSURFACEDESC *format, IDirectDrawPalette *palette) { struct ddraw_stream *stream = impl_from_IDirectDrawMediaStream(iface); + ALLOCATOR_PROPERTIES new_props, ret_props; AM_MEDIA_TYPE old_media_type; struct format old_format; IPin *old_peer; @@ -710,9 +711,20 @@ static HRESULT WINAPI ddraw_IDirectDrawMediaStream_SetFormat(IDirectDrawMediaStr FreeMediaType(&old_media_type); }
+ /* Set private allocator sample size */ + IMemAllocator_GetProperties(stream->private_allocator, &new_props); + new_props.cbBuffer = stream->format.width * stream->format.height * (stream->format.pf.dwRGBBitCount / 8); + hr = IMemAllocator_SetProperties(stream->private_allocator, &new_props, &ret_props); + if (hr == VFW_E_ALREADY_COMMITTED) + { + IMemAllocator_Decommit(stream->private_allocator); + hr = IMemAllocator_SetProperties(stream->private_allocator, &new_props, &ret_props); + IMemAllocator_Commit(stream->private_allocator); + } + LeaveCriticalSection(&stream->cs);
- return S_OK; + return hr; }
static HRESULT WINAPI ddraw_IDirectDrawMediaStream_GetDirectDraw(IDirectDrawMediaStream *iface, @@ -1362,10 +1374,15 @@ static ULONG WINAPI ddraw_mem_allocator_Release(IMemAllocator *iface) static HRESULT WINAPI ddraw_mem_allocator_SetProperties(IMemAllocator *iface, ALLOCATOR_PROPERTIES *req_props, ALLOCATOR_PROPERTIES *ret_props) { + ALLOCATOR_PROPERTIES orig_props; struct ddraw_stream *stream = impl_from_IMemAllocator(iface);
TRACE("stream %p, req_props %p, ret_props %p.\n", stream, req_props, ret_props);
+ IMemAllocator_GetProperties(stream->private_allocator, &orig_props); + req_props->cbBuffer = orig_props.cbBuffer; + req_props->cBuffers = req_props->cBuffers > 0 ? req_props->cBuffers : 1; + return IMemAllocator_SetProperties(stream->private_allocator, req_props, ret_props); }
diff --git a/dlls/amstream/tests/amstream.c b/dlls/amstream/tests/amstream.c index b3fa59f6dab..2c05bcffd92 100644 --- a/dlls/amstream/tests/amstream.c +++ b/dlls/amstream/tests/amstream.c @@ -8549,7 +8549,7 @@ static void test_ddrawstream_mem_allocator(void) props.cbPrefix = 0; hr = IMemAllocator_SetProperties(ddraw_allocator, &props, &ret_props); ok(hr == S_OK, "Got hr %#lx.\n", hr); - todo_wine ok(ret_props.cbBuffer == 10000, "Expected sample size to be 10000 got %ld\n", ret_props.cbBuffer); + ok(ret_props.cbBuffer == 10000, "Expected sample size to be 10000 got %ld\n", ret_props.cbBuffer); ok(ret_props.cBuffers == 4, "Expected 4 samples got %ld\n", ret_props.cBuffers); ok(ret_props.cbAlign == 1, "Expected alignment of 1 got %ld\n", ret_props.cbAlign);
@@ -8559,7 +8559,7 @@ static void test_ddrawstream_mem_allocator(void)
hr = IMemAllocator_GetProperties(ddraw_allocator, &props); ok(hr == S_OK, "Got hr %#lx.\n", hr); - todo_wine ok(props.cbBuffer == 40000, "Expected sample size to be 40000 got %ld\n", props.cbBuffer); + ok(props.cbBuffer == 40000, "Expected sample size to be 40000 got %ld\n", props.cbBuffer); ok(props.cBuffers == 4, "Expected 4 samples got %ld\n", props.cBuffers); ok(props.cbAlign == 1, "Expected alignment of 1 got %ld\n", props.cbAlign);
@@ -8569,8 +8569,8 @@ static void test_ddrawstream_mem_allocator(void) props.cbPrefix = 0; hr = IMemAllocator_SetProperties(ddraw_allocator, &props, &ret_props); ok(hr == S_OK, "Got hr %#lx.\n", hr); - todo_wine ok(ret_props.cbBuffer == 40000, "Expected sample size to be 40000 got %ld\n", ret_props.cbBuffer); - todo_wine ok(ret_props.cBuffers == 1, "Expected 1 sample got %ld\n", ret_props.cBuffers); + ok(ret_props.cbBuffer == 40000, "Expected sample size to be 40000 got %ld\n", ret_props.cbBuffer); + ok(ret_props.cBuffers == 1, "Expected 1 sample got %ld\n", ret_props.cBuffers); ok(ret_props.cbAlign == 1, "Expected alignment of 1 got %ld\n", ret_props.cbAlign);
/* Try setting a larger buffer size. */ @@ -8580,7 +8580,7 @@ static void test_ddrawstream_mem_allocator(void) props.cbPrefix = 0; hr = IMemAllocator_SetProperties(ddraw_allocator, &props, &ret_props); ok(hr == S_OK, "Got hr %#lx.\n", hr); - todo_wine ok(ret_props.cbBuffer == 40000, "Expected sample size to be 40000 got %ld\n", ret_props.cbBuffer); + ok(ret_props.cbBuffer == 40000, "Expected sample size to be 40000 got %ld\n", ret_props.cbBuffer); ok(ret_props.cBuffers == 1, "Expected 1 sample got %ld\n", ret_props.cBuffers); ok(ret_props.cbAlign == 1, "Expected alignment of 1 got %ld\n", ret_props.cbAlign);
@@ -8592,7 +8592,7 @@ static void test_ddrawstream_mem_allocator(void)
hr = IMemAllocator_GetProperties(ddraw_allocator, &props); ok(hr == S_OK, "Got hr %#lx.\n", hr); - todo_wine ok(props.cbBuffer == 20000, "Expected sample size to be 20000 got %ld\n", props.cbBuffer); + ok(props.cbBuffer == 20000, "Expected sample size to be 20000 got %ld\n", props.cbBuffer); ok(props.cBuffers == 1, "Expected 1 samples got %ld\n", props.cBuffers); ok(props.cbAlign == 1, "Expected alignment of 1 got %ld\n", props.cbAlign);
@@ -8664,7 +8664,7 @@ static void test_ddrawstream_mem_allocator(void)
hr = IMemAllocator_GetProperties(ddraw_allocator, &props); ok(hr == S_OK, "Got hr %#lx.\n", hr); - todo_wine ok(props.cbBuffer == 333 * 444 * 4, "Got sample size %ld\n", props.cbBuffer); + ok(props.cbBuffer == 333 * 444 * 4, "Got sample size %ld\n", props.cbBuffer); ok(props.cBuffers == 2, "Expected 2 samples got %ld\n", props.cBuffers); ok(props.cbAlign == 1, "Expected alignment of 1 got %ld\n", props.cbAlign);