winegstreamer: Implement INSSBuffer::GetBufferAndLength().

Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zebediah Figura 2021-10-31 19:03:34 -05:00 committed by Alexandre Julliard
parent 3b8579d8a5
commit 538b86bfc6
2 changed files with 20 additions and 4 deletions

View File

@ -171,6 +171,9 @@ struct buffer
{ {
INSSBuffer INSSBuffer_iface; INSSBuffer INSSBuffer_iface;
LONG refcount; LONG refcount;
DWORD size;
BYTE data[1];
}; };
static struct buffer *impl_from_INSSBuffer(INSSBuffer *iface) 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) static HRESULT WINAPI buffer_GetBufferAndLength(INSSBuffer *iface, BYTE **data, DWORD *size)
{ {
FIXME("iface %p, data %p, size %p, stub!\n", iface, data, size); struct buffer *buffer = impl_from_INSSBuffer(iface);
return E_NOTIMPL;
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 = static const INSSBufferVtbl buffer_vtbl =
@ -1579,7 +1587,7 @@ HRESULT wm_reader_get_stream_sample(struct wm_stream *stream,
{ {
case WG_PARSER_EVENT_BUFFER: case WG_PARSER_EVENT_BUFFER:
/* FIXME: Should these be pooled? */ /* 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); wg_parser_stream_release_buffer(wg_stream);
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
@ -1587,6 +1595,14 @@ HRESULT wm_reader_get_stream_sample(struct wm_stream *stream,
object->INSSBuffer_iface.lpVtbl = &buffer_vtbl; object->INSSBuffer_iface.lpVtbl = &buffer_vtbl;
object->refcount = 1; 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); wg_parser_stream_release_buffer(wg_stream);

View File

@ -509,7 +509,7 @@ static void test_sync_reader_streaming(void)
if (hr == S_OK) if (hr == S_OK)
{ {
hr = INSSBuffer_GetBufferAndLength(sample, &data, &size); 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); ref = INSSBuffer_Release(sample);
ok(!ref, "Got outstanding refcount %d.\n", ref); ok(!ref, "Got outstanding refcount %d.\n", ref);