Module: wine Branch: master Commit: 5aa60f778a2ab88491d61a0dd267ad6bf897e8fe URL: https://gitlab.winehq.org/wine/wine/-/commit/5aa60f778a2ab88491d61a0dd267ad6...
Author: Rémi Bernon rbernon@codeweavers.com Date: Fri Sep 23 16:54:42 2022 +0200
winegstreamer: Implement IWMSyncReader2_SetAllocateForStream.
---
dlls/winegstreamer/gst_private.h | 1 + dlls/winegstreamer/wm_reader.c | 28 ++++++++++++++++++++++++---- dlls/wmvcore/tests/wmvcore.c | 5 ----- 3 files changed, 25 insertions(+), 9 deletions(-)
diff --git a/dlls/winegstreamer/gst_private.h b/dlls/winegstreamer/gst_private.h index 44b526c0044..fa93ce969c7 100644 --- a/dlls/winegstreamer/gst_private.h +++ b/dlls/winegstreamer/gst_private.h @@ -160,6 +160,7 @@ struct wm_stream bool read_compressed;
IWMReaderAllocatorEx *output_allocator; + IWMReaderAllocatorEx *stream_allocator; };
struct wm_reader diff --git a/dlls/winegstreamer/wm_reader.c b/dlls/winegstreamer/wm_reader.c index 01766397aa4..6c9c0514347 100644 --- a/dlls/winegstreamer/wm_reader.c +++ b/dlls/winegstreamer/wm_reader.c @@ -1623,6 +1623,9 @@ HRESULT wm_reader_get_stream_sample(struct wm_reader *reader, IWMReaderCallbackA if (!stream->read_compressed && stream->output_allocator) hr = IWMReaderAllocatorEx_AllocateForOutputEx(stream->output_allocator, stream->index, wg_buffer.size, &sample, 0, 0, 0, NULL); + else if (stream->read_compressed && stream->stream_allocator) + hr = IWMReaderAllocatorEx_AllocateForStreamEx(stream->stream_allocator, stream->index + 1, + wg_buffer.size, &sample, 0, 0, 0, NULL); else if (callback_advanced && stream->read_compressed && stream->allocate_stream) hr = IWMReaderCallbackAdvanced_AllocateForStream(callback_advanced, stream->index + 1, wg_buffer.size, &sample, NULL); @@ -2470,11 +2473,28 @@ static HRESULT WINAPI reader_GetAllocateForOutput(IWMSyncReader2 *iface, DWORD o return S_OK; }
-static HRESULT WINAPI reader_SetAllocateForStream(IWMSyncReader2 *iface, DWORD stream_num, IWMReaderAllocatorEx *allocator) +static HRESULT WINAPI reader_SetAllocateForStream(IWMSyncReader2 *iface, DWORD stream_number, IWMReaderAllocatorEx *allocator) { - struct wm_reader *This = impl_from_IWMSyncReader2(iface); - FIXME("(%p)->(%lu %p): stub!\n", This, stream_num, allocator); - return E_NOTIMPL; + struct wm_reader *reader = impl_from_IWMSyncReader2(iface); + struct wm_stream *stream; + + TRACE("reader %p, stream_number %lu, allocator %p.\n", reader, stream_number, allocator); + + EnterCriticalSection(&reader->cs); + + if (!(stream = wm_reader_get_stream_by_stream_number(reader, stream_number))) + { + LeaveCriticalSection(&reader->cs); + return E_INVALIDARG; + } + + if (stream->stream_allocator) + IWMReaderAllocatorEx_Release(stream->stream_allocator); + if ((stream->stream_allocator = allocator)) + IWMReaderAllocatorEx_AddRef(stream->stream_allocator); + + LeaveCriticalSection(&reader->cs); + return S_OK; }
static HRESULT WINAPI reader_GetAllocateForStream(IWMSyncReader2 *iface, DWORD stream_num, IWMReaderAllocatorEx **allocator) diff --git a/dlls/wmvcore/tests/wmvcore.c b/dlls/wmvcore/tests/wmvcore.c index a7ebbb916b2..948d6b54340 100644 --- a/dlls/wmvcore/tests/wmvcore.c +++ b/dlls/wmvcore/tests/wmvcore.c @@ -3491,7 +3491,6 @@ static void test_sync_reader_allocator(void) hr = IWMSyncReader2_SetAllocateForOutput(reader, -1, &callback.IWMReaderAllocatorEx_iface); ok(hr == E_INVALIDARG, "Got hr %#lx.\n", hr); hr = IWMSyncReader2_SetAllocateForStream(reader, 0, &callback.IWMReaderAllocatorEx_iface); - todo_wine ok(hr == E_INVALIDARG, "Got hr %#lx.\n", hr);
@@ -3508,7 +3507,6 @@ static void test_sync_reader_allocator(void)
hr = IWMSyncReader2_SetAllocateForStream(reader, 1, &callback.IWMReaderAllocatorEx_iface); - todo_wine ok(hr == S_OK, "Got hr %#lx.\n", hr); allocator = (void *)0xdeadbeef; hr = IWMSyncReader2_GetAllocateForOutput(reader, 0, &allocator); @@ -3527,7 +3525,6 @@ static void test_sync_reader_allocator(void) ok(allocator == &callback.IWMReaderAllocatorEx_iface, "Got allocator %p.\n", allocator);
hr = IWMSyncReader2_SetAllocateForStream(reader, 1, NULL); - todo_wine ok(hr == S_OK, "Got hr %#lx.\n", hr); allocator = (void *)0xdeadbeef; hr = IWMSyncReader2_GetAllocateForOutput(reader, 0, &allocator); @@ -3574,7 +3571,6 @@ static void test_sync_reader_allocator(void) hr = IWMSyncReader2_GetStreamNumberForOutput(reader, 0, &stream_num); ok(hr == S_OK, "Got hr %#lx.\n", hr); hr = IWMSyncReader2_SetAllocateForStream(reader, stream_num, &callback.IWMReaderAllocatorEx_iface); - todo_wine ok(hr == S_OK, "Got hr %#lx.\n", hr); hr = IWMSyncReader2_SetReadStreamSamples(reader, stream_num, TRUE); ok(hr == S_OK, "Got hr %#lx.\n", hr); @@ -3588,7 +3584,6 @@ static void test_sync_reader_allocator(void) hr = IWMSyncReader2_GetNextSample(reader, stream_num, &sample, &pts, &duration, &flags, &output_num, &stream_num); ok(hr == S_OK, "Got hr %#lx.\n", hr); - todo_wine ok(sample->lpVtbl == &buffer_vtbl, "Buffer vtbl didn't match.\n"); INSSBuffer_Release(sample);