From 538b86bfc640ddcfd4d28b1e2660acdef0ce9b08 Mon Sep 17 00:00:00 2001 From: Zebediah Figura Date: Sun, 31 Oct 2021 19:03:34 -0500 Subject: [PATCH] winegstreamer: Implement INSSBuffer::GetBufferAndLength(). Signed-off-by: Zebediah Figura Signed-off-by: Alexandre Julliard --- dlls/winegstreamer/wm_reader.c | 22 +++++++++++++++++++--- dlls/wmvcore/tests/wmvcore.c | 2 +- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/dlls/winegstreamer/wm_reader.c b/dlls/winegstreamer/wm_reader.c index 71adfac5a42..e708ed4bfa6 100644 --- a/dlls/winegstreamer/wm_reader.c +++ b/dlls/winegstreamer/wm_reader.c @@ -171,6 +171,9 @@ struct buffer { INSSBuffer INSSBuffer_iface; LONG refcount; + + DWORD size; + BYTE data[1]; }; static struct buffer *impl_from_INSSBuffer(INSSBuffer *iface) @@ -246,8 +249,13 @@ static HRESULT WINAPI buffer_GetBuffer(INSSBuffer *iface, BYTE **data) static HRESULT WINAPI buffer_GetBufferAndLength(INSSBuffer *iface, BYTE **data, DWORD *size) { - FIXME("iface %p, data %p, size %p, stub!\n", iface, data, size); - return E_NOTIMPL; + struct buffer *buffer = impl_from_INSSBuffer(iface); + + TRACE("buffer %p, data %p, size %p.\n", buffer, data, size); + + *size = buffer->size; + *data = buffer->data; + return S_OK; } static const INSSBufferVtbl buffer_vtbl = @@ -1579,7 +1587,7 @@ HRESULT wm_reader_get_stream_sample(struct wm_stream *stream, { case WG_PARSER_EVENT_BUFFER: /* FIXME: Should these be pooled? */ - if (!(object = calloc(1, sizeof(*object)))) + if (!(object = calloc(1, offsetof(struct buffer, data[event.u.buffer.size])))) { wg_parser_stream_release_buffer(wg_stream); return E_OUTOFMEMORY; @@ -1587,6 +1595,14 @@ HRESULT wm_reader_get_stream_sample(struct wm_stream *stream, object->INSSBuffer_iface.lpVtbl = &buffer_vtbl; object->refcount = 1; + object->size = event.u.buffer.size; + + if (!wg_parser_stream_copy_buffer(wg_stream, object->data, 0, object->size)) + { + /* The GStreamer pin has been flushed. */ + free(object); + break; + } wg_parser_stream_release_buffer(wg_stream); diff --git a/dlls/wmvcore/tests/wmvcore.c b/dlls/wmvcore/tests/wmvcore.c index dabeb054530..419dea2f68d 100644 --- a/dlls/wmvcore/tests/wmvcore.c +++ b/dlls/wmvcore/tests/wmvcore.c @@ -509,7 +509,7 @@ static void test_sync_reader_streaming(void) if (hr == S_OK) { hr = INSSBuffer_GetBufferAndLength(sample, &data, &size); - todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(hr == S_OK, "Got hr %#x.\n", hr); ref = INSSBuffer_Release(sample); ok(!ref, "Got outstanding refcount %d.\n", ref);