Module: wine Branch: master Commit: 7eb50d5e5703dc660945554da70cae37324bb39c URL: https://gitlab.winehq.org/wine/wine/-/commit/7eb50d5e5703dc660945554da70cae3...
Author: Rémi Bernon rbernon@codeweavers.com Date: Mon Aug 22 14:57:10 2022 +0200
winegstreamer: Implement IWMSyncReader2_SetAllocateForOutput.
---
dlls/winegstreamer/gst_private.h | 2 ++ dlls/winegstreamer/wm_reader.c | 30 +++++++++++++++++++++++++----- dlls/wmvcore/tests/wmvcore.c | 5 ----- 3 files changed, 27 insertions(+), 10 deletions(-)
diff --git a/dlls/winegstreamer/gst_private.h b/dlls/winegstreamer/gst_private.h index 178679c38ee..44b526c0044 100644 --- a/dlls/winegstreamer/gst_private.h +++ b/dlls/winegstreamer/gst_private.h @@ -158,6 +158,8 @@ struct wm_stream * compressed samples. Rather, the behaviour of the reader objects differs * in nontrivial ways depending on this field. */ bool read_compressed; + + IWMReaderAllocatorEx *output_allocator; };
struct wm_reader diff --git a/dlls/winegstreamer/wm_reader.c b/dlls/winegstreamer/wm_reader.c index 4839ddb8fa3..916bfb68ea8 100644 --- a/dlls/winegstreamer/wm_reader.c +++ b/dlls/winegstreamer/wm_reader.c @@ -1620,7 +1620,10 @@ HRESULT wm_reader_get_stream_sample(struct wm_reader *reader, IWMReaderCallbackA
TRACE("Got buffer for '%s' stream %p.\n", get_major_type_string(stream->format.major_type), stream);
- if (callback_advanced && stream->read_compressed && stream->allocate_stream) + 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 (callback_advanced && stream->read_compressed && stream->allocate_stream) hr = IWMReaderCallbackAdvanced_AllocateForStream(callback_advanced, stream->index + 1, wg_buffer.size, &sample, NULL); else if (callback_advanced && !stream->read_compressed && stream->allocate_output) @@ -2417,11 +2420,28 @@ static HRESULT WINAPI reader_SetRangeByFrameEx(IWMSyncReader2 *iface, WORD strea return E_NOTIMPL; }
-static HRESULT WINAPI reader_SetAllocateForOutput(IWMSyncReader2 *iface, DWORD output_num, IWMReaderAllocatorEx *allocator) +static HRESULT WINAPI reader_SetAllocateForOutput(IWMSyncReader2 *iface, DWORD output, IWMReaderAllocatorEx *allocator) { - struct wm_reader *This = impl_from_IWMSyncReader2(iface); - FIXME("(%p)->(%lu %p): stub!\n", This, output_num, allocator); - return E_NOTIMPL; + struct wm_reader *reader = impl_from_IWMSyncReader2(iface); + struct wm_stream *stream; + + TRACE("reader %p, output %lu, allocator %p.\n", reader, output, allocator); + + EnterCriticalSection(&reader->cs); + + if (!(stream = get_stream_by_output_number(reader, output))) + { + LeaveCriticalSection(&reader->cs); + return E_INVALIDARG; + } + + if (stream->output_allocator) + IWMReaderAllocatorEx_Release(stream->output_allocator); + if ((stream->output_allocator = allocator)) + IWMReaderAllocatorEx_AddRef(stream->output_allocator); + + LeaveCriticalSection(&reader->cs); + return S_OK; }
static HRESULT WINAPI reader_GetAllocateForOutput(IWMSyncReader2 *iface, DWORD output_num, IWMReaderAllocatorEx **allocator) diff --git a/dlls/wmvcore/tests/wmvcore.c b/dlls/wmvcore/tests/wmvcore.c index 46e15c922c3..33f61889415 100644 --- a/dlls/wmvcore/tests/wmvcore.c +++ b/dlls/wmvcore/tests/wmvcore.c @@ -3491,7 +3491,6 @@ static void test_sync_reader_allocator(void) todo_wine ok(hr == E_INVALIDARG, "Got hr %#lx.\n", hr); hr = IWMSyncReader2_SetAllocateForOutput(reader, -1, &callback.IWMReaderAllocatorEx_iface); - todo_wine ok(hr == E_INVALIDARG, "Got hr %#lx.\n", hr); hr = IWMSyncReader2_SetAllocateForStream(reader, 0, &callback.IWMReaderAllocatorEx_iface); todo_wine @@ -3551,7 +3550,6 @@ static void test_sync_reader_allocator(void)
hr = IWMSyncReader2_SetAllocateForOutput(reader, 0, &callback.IWMReaderAllocatorEx_iface); - todo_wine ok(hr == S_OK, "Got hr %#lx.\n", hr); allocator = (void *)0xdeadbeef; hr = IWMSyncReader2_GetAllocateForOutput(reader, 1, &allocator); @@ -3572,7 +3570,6 @@ static void test_sync_reader_allocator(void) ok(allocator == &callback.IWMReaderAllocatorEx_iface, "Got allocator %p.\n", allocator);
hr = IWMSyncReader2_SetAllocateForOutput(reader, 0, NULL); - todo_wine ok(hr == S_OK, "Got hr %#lx.\n", hr); allocator = (void *)0xdeadbeef; hr = IWMSyncReader2_GetAllocateForOutput(reader, 0, &allocator); @@ -3596,7 +3593,6 @@ static void test_sync_reader_allocator(void) hr = IWMSyncReader2_SetReadStreamSamples(reader, stream_num, TRUE); ok(hr == S_OK, "Got hr %#lx.\n", hr); hr = IWMSyncReader2_SetAllocateForOutput(reader, 1, &callback.IWMReaderAllocatorEx_iface); - todo_wine ok(hr == S_OK, "Got hr %#lx.\n", hr);
callback.allocated_samples = true; @@ -3615,7 +3611,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);