Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/winegstreamer/gst_private.h | 4 ++++ dlls/winegstreamer/gstdemux.c | 21 +++++++------------ dlls/winegstreamer/wg_parser.c | 35 ++++++++++++++++++++++++++++++++ 3 files changed, 46 insertions(+), 14 deletions(-)
diff --git a/dlls/winegstreamer/gst_private.h b/dlls/winegstreamer/gst_private.h index 068cb47adc2..33c87f2c1ec 100644 --- a/dlls/winegstreamer/gst_private.h +++ b/dlls/winegstreamer/gst_private.h @@ -226,6 +226,10 @@ struct unix_funcs void (CDECL *wg_parser_begin_flush)(struct wg_parser *parser); void (CDECL *wg_parser_end_flush)(struct wg_parser *parser);
+ bool (CDECL *wg_parser_get_read_request)(struct wg_parser *parser, + GstBuffer **buffer, uint64_t *offset, uint32_t *size); + void (CDECL *wg_parser_complete_read_request)(struct wg_parser *parser, GstFlowReturn ret); + uint32_t (CDECL *wg_parser_get_stream_count)(struct wg_parser *parser); struct wg_parser_stream *(CDECL *wg_parser_get_stream)(struct wg_parser *parser, uint32_t index);
diff --git a/dlls/winegstreamer/gstdemux.c b/dlls/winegstreamer/gstdemux.c index 2a7383111b1..4e476c78e9e 100644 --- a/dlls/winegstreamer/gstdemux.c +++ b/dlls/winegstreamer/gstdemux.c @@ -822,29 +822,22 @@ static GstFlowReturn read_buffer(struct parser *This, guint64 ofs, guint len, Gs static DWORD CALLBACK read_thread(void *arg) { struct parser *filter = arg; - struct wg_parser *parser = filter->wg_parser;
TRACE("Starting read thread for filter %p.\n", filter);
- pthread_mutex_lock(&parser->mutex); - while (filter->sink_connected) { - while (parser->sink_connected && !parser->read_request.buffer) - pthread_cond_wait(&parser->read_cond, &parser->mutex); + GstBuffer *buffer; + uint64_t offset; + uint32_t size;
- if (!parser->sink_connected) - break; + if (!unix_funcs->wg_parser_get_read_request(filter->wg_parser, &buffer, &offset, &size)) + continue;
- parser->read_request.done = true; - parser->read_request.ret = read_buffer(filter, parser->read_request.offset, - parser->read_request.size, parser->read_request.buffer); - parser->read_request.buffer = NULL; - pthread_cond_signal(&parser->read_done_cond); + unix_funcs->wg_parser_complete_read_request(filter->wg_parser, + read_buffer(filter, offset, size, buffer)); }
- pthread_mutex_unlock(&parser->mutex); - TRACE("Streaming stopped; exiting.\n"); return 0; } diff --git a/dlls/winegstreamer/wg_parser.c b/dlls/winegstreamer/wg_parser.c index de066f83881..96c6fc1e715 100644 --- a/dlls/winegstreamer/wg_parser.c +++ b/dlls/winegstreamer/wg_parser.c @@ -349,6 +349,38 @@ static void CDECL wg_parser_end_flush(struct wg_parser *parser) pthread_mutex_unlock(&parser->mutex); }
+static bool CDECL wg_parser_get_read_request(struct wg_parser *parser, + GstBuffer **buffer, uint64_t *offset, uint32_t *size) +{ + pthread_mutex_lock(&parser->mutex); + + while (parser->sink_connected && !parser->read_request.buffer) + pthread_cond_wait(&parser->read_cond, &parser->mutex); + + if (!parser->sink_connected) + { + pthread_mutex_unlock(&parser->mutex); + return false; + } + + *buffer = parser->read_request.buffer; + *offset = parser->read_request.offset; + *size = parser->read_request.size; + + pthread_mutex_unlock(&parser->mutex); + return true; +} + +static void CDECL wg_parser_complete_read_request(struct wg_parser *parser, GstFlowReturn ret) +{ + pthread_mutex_lock(&parser->mutex); + parser->read_request.done = true; + parser->read_request.ret = ret; + parser->read_request.buffer = NULL; + pthread_mutex_unlock(&parser->mutex); + pthread_cond_signal(&parser->read_done_cond); +} + static void CDECL wg_parser_stream_get_preferred_format(struct wg_parser_stream *stream, struct wg_format *format) { *format = stream->preferred_format; @@ -1663,6 +1695,9 @@ static const struct unix_funcs funcs = wg_parser_begin_flush, wg_parser_end_flush,
+ wg_parser_get_read_request, + wg_parser_complete_read_request, + wg_parser_get_stream_count, wg_parser_get_stream,