From: Rémi Bernon rbernon@codeweavers.com
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/winegstreamer/wg_parser.c | 41 ++++++++++++++-------------------- 1 file changed, 17 insertions(+), 24 deletions(-)
diff --git a/dlls/winegstreamer/wg_parser.c b/dlls/winegstreamer/wg_parser.c index ca95f187aea..865b6d3643a 100644 --- a/dlls/winegstreamer/wg_parser.c +++ b/dlls/winegstreamer/wg_parser.c @@ -155,33 +155,26 @@ static NTSTATUS wg_parser_push_data(void *args) struct wg_parser *parser = params->parser; const void *data = params->data; uint32_t size = params->size; - - pthread_mutex_lock(&parser->mutex); - - if (data) - { - if (size) - { - GstMapInfo map_info; - - /* Note that we don't allocate the buffer until we have a size. - * midiparse passes a NULL buffer and a size of UINT_MAX, in an - * apparent attempt to read the whole input stream at once. */ - parser->read_request.buffer = gst_buffer_new_and_alloc(size); - gst_buffer_map(parser->read_request.buffer, &map_info, GST_MAP_WRITE); - memcpy(map_info.data, data, size); - gst_buffer_unmap(parser->read_request.buffer, &map_info); - parser->read_request.ret = GST_FLOW_OK; - } - else - { - parser->read_request.ret = GST_FLOW_EOS; - } - } + GstBuffer *buffer = NULL; + GstFlowReturn result; + + if (!data) + result = GST_FLOW_ERROR; + else if (!size) + result = GST_FLOW_EOS; + else if (!(buffer = gst_buffer_new_and_alloc(size))) + result = GST_FLOW_ERROR; else { - parser->read_request.ret = GST_FLOW_ERROR; + gst_buffer_fill(buffer, 0, data, size); + GST_INFO("Copied %u bytes from data %p to buffer %p", size, data, buffer); + result = GST_FLOW_OK; } + + pthread_mutex_lock(&parser->mutex); + + parser->read_request.ret = result; + parser->read_request.buffer = buffer; parser->read_request.done = true; parser->read_request.size = 0;