Commit 45598d76 authored by Rémi Bernon's avatar Rémi Bernon Committed by Alexandre Julliard

winegstreamer: Factor wm reader sample allocator error checks.

parent 42e98094
......@@ -1573,9 +1573,10 @@ HRESULT wm_reader_get_stream_sample(struct wm_reader *reader, IWMReaderCallbackA
struct wg_parser_stream *wg_stream;
struct wg_parser_buffer wg_buffer;
struct wm_stream *stream;
struct buffer *object;
DWORD size, capacity;
INSSBuffer *sample;
HRESULT hr;
HRESULT hr = S_OK;
BYTE *data;
for (;;)
......@@ -1620,36 +1621,16 @@ 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 (FAILED(hr = IWMReaderCallbackAdvanced_AllocateForStream(callback_advanced,
stream->index + 1, wg_buffer.size, &sample, NULL)))
{
ERR("Failed to allocate stream sample of %u bytes, hr %#lx.\n", wg_buffer.size, hr);
wg_parser_stream_release_buffer(wg_stream);
return hr;
}
}
hr = IWMReaderCallbackAdvanced_AllocateForStream(callback_advanced,
stream->index + 1, wg_buffer.size, &sample, NULL);
else if (callback_advanced && !stream->read_compressed && stream->allocate_output)
{
if (FAILED(hr = IWMReaderCallbackAdvanced_AllocateForOutput(callback_advanced,
stream->index, wg_buffer.size, &sample, NULL)))
{
ERR("Failed to allocate output sample of %u bytes, hr %#lx.\n", wg_buffer.size, hr);
wg_parser_stream_release_buffer(wg_stream);
return hr;
}
}
hr = IWMReaderCallbackAdvanced_AllocateForOutput(callback_advanced,
stream->index, wg_buffer.size, &sample, NULL);
/* FIXME: Should these be pooled? */
else if (!(object = calloc(1, offsetof(struct buffer, data[wg_buffer.size]))))
hr = E_OUTOFMEMORY;
else
{
struct buffer *object;
/* FIXME: Should these be pooled? */
if (!(object = calloc(1, offsetof(struct buffer, data[wg_buffer.size]))))
{
wg_parser_stream_release_buffer(wg_stream);
return E_OUTOFMEMORY;
}
object->INSSBuffer_iface.lpVtbl = &buffer_vtbl;
object->refcount = 1;
object->capacity = wg_buffer.size;
......@@ -1658,6 +1639,13 @@ HRESULT wm_reader_get_stream_sample(struct wm_reader *reader, IWMReaderCallbackA
sample = &object->INSSBuffer_iface;
}
if (FAILED(hr))
{
ERR("Failed to allocate sample of %u bytes, hr %#lx.\n", wg_buffer.size, hr);
wg_parser_stream_release_buffer(wg_stream);
return hr;
}
if (FAILED(hr = INSSBuffer_GetBufferAndLength(sample, &data, &size)))
ERR("Failed to get data pointer, hr %#lx.\n", hr);
if (FAILED(hr = INSSBuffer_GetMaxLength(sample, &capacity)))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment