From: Rémi Bernon rbernon@codeweavers.com
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/winegstreamer/wg_parser.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-)
diff --git a/dlls/winegstreamer/wg_parser.c b/dlls/winegstreamer/wg_parser.c index 7d55897aa0a..6b1a98c0e7d 100644 --- a/dlls/winegstreamer/wg_parser.c +++ b/dlls/winegstreamer/wg_parser.c @@ -103,7 +103,6 @@ struct wg_parser_stream
pthread_cond_t event_cond, event_empty_cond; GstBuffer *buffer; - GstMapInfo map_info;
bool flushing, eos, enabled, has_caps;
@@ -306,6 +305,7 @@ static NTSTATUS wg_parser_stream_copy_buffer(void *args) struct wg_parser *parser = stream->parser; uint32_t offset = params->offset; uint32_t size = params->size; + GstMapInfo map_info;
pthread_mutex_lock(&parser->mutex);
@@ -315,9 +315,18 @@ static NTSTATUS wg_parser_stream_copy_buffer(void *args) return VFW_E_WRONG_STATE; }
- assert(offset < stream->map_info.size); - assert(offset + size <= stream->map_info.size); - memcpy(params->data, stream->map_info.data + offset, size); + if (!gst_buffer_map(stream->buffer, &map_info, GST_MAP_READ)) + { + pthread_mutex_unlock(&parser->mutex); + GST_ERROR("Failed to map buffer.\n"); + return E_FAIL; + } + + assert(offset < map_info.size); + assert(offset + size <= map_info.size); + memcpy(params->data, map_info.data + offset, size); + + gst_buffer_unmap(stream->buffer, &map_info);
pthread_mutex_unlock(&parser->mutex); return S_OK; @@ -332,7 +341,6 @@ static NTSTATUS wg_parser_stream_release_buffer(void *args)
assert(stream->buffer);
- gst_buffer_unmap(stream->buffer, &stream->map_info); gst_buffer_unref(stream->buffer); stream->buffer = NULL;
@@ -486,7 +494,6 @@ static gboolean sink_event_cb(GstPad *pad, GstObject *parent, GstEvent *event)
if (stream->buffer) { - gst_buffer_unmap(stream->buffer, &stream->map_info); gst_buffer_unref(stream->buffer); stream->buffer = NULL; } @@ -564,14 +571,6 @@ static GstFlowReturn sink_chain_cb(GstPad *pad, GstObject *parent, GstBuffer *bu return GST_FLOW_FLUSHING; }
- if (!gst_buffer_map(buffer, &stream->map_info, GST_MAP_READ)) - { - pthread_mutex_unlock(&parser->mutex); - GST_ERROR("Failed to map buffer.\n"); - gst_buffer_unref(buffer); - return GST_FLOW_ERROR; - } - stream->buffer = buffer;
pthread_mutex_unlock(&parser->mutex);