diff --git a/dlls/winegstreamer/gst_private.h b/dlls/winegstreamer/gst_private.h index 08ff6ee21f0..ee698bdf32f 100644 --- a/dlls/winegstreamer/gst_private.h +++ b/dlls/winegstreamer/gst_private.h @@ -215,6 +215,9 @@ struct unix_funcs HRESULT (CDECL *wg_parser_connect)(struct wg_parser *parser, uint64_t file_size); void (CDECL *wg_parser_disconnect)(struct wg_parser *parser); + void (CDECL *wg_parser_begin_flush)(struct wg_parser *parser); + void (CDECL *wg_parser_end_flush)(struct wg_parser *parser); + 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 d4614ca5a65..63368febc5c 100644 --- a/dlls/winegstreamer/gstdemux.c +++ b/dlls/winegstreamer/gstdemux.c @@ -856,9 +856,7 @@ static HRESULT parser_init_stream(struct strmbase_filter *iface) return S_OK; filter->streaming = true; - pthread_mutex_lock(&parser->mutex); - parser->flushing = false; - pthread_mutex_unlock(&parser->mutex); + unix_funcs->wg_parser_end_flush(filter->wg_parser); /* DirectShow retains the old seek positions, but resets to them every time * it transitions from stopped -> paused. */ @@ -899,17 +897,7 @@ static HRESULT parser_cleanup_stream(struct strmbase_filter *iface) return S_OK; filter->streaming = false; - pthread_mutex_lock(&parser->mutex); - parser->flushing = true; - pthread_mutex_unlock(&parser->mutex); - - for (i = 0; i < parser->stream_count; ++i) - { - struct wg_parser_stream *stream = parser->streams[i]; - - if (stream->enabled) - pthread_cond_signal(&stream->event_cond); - } + unix_funcs->wg_parser_begin_flush(filter->wg_parser); for (i = 0; i < filter->source_count; ++i) { @@ -1228,7 +1216,6 @@ static HRESULT WINAPI GST_Seeking_SetPositions(IMediaSeeking *iface, struct parser_source *pin = impl_from_IMediaSeeking(iface); struct wg_parser_stream *stream = pin->wg_stream; struct parser *filter = impl_from_strmbase_filter(pin->pin.pin.filter); - struct wg_parser *parser = filter->wg_parser; GstSeekFlags flags = 0; HRESULT hr = S_OK; int i; @@ -1247,17 +1234,12 @@ static HRESULT WINAPI GST_Seeking_SetPositions(IMediaSeeking *iface, if (!(current_flags & AM_SEEKING_NoFlush)) { - pthread_mutex_lock(&parser->mutex); - parser->flushing = true; - pthread_mutex_unlock(&parser->mutex); + unix_funcs->wg_parser_begin_flush(filter->wg_parser); for (i = 0; i < filter->source_count; ++i) { if (filter->sources[i]->pin.pin.peer) - { - pthread_cond_signal(&stream->event_cond); IPin_BeginFlush(filter->sources[i]->pin.pin.peer); - } } if (filter->reader) @@ -1296,9 +1278,7 @@ static HRESULT WINAPI GST_Seeking_SetPositions(IMediaSeeking *iface, if (!(current_flags & AM_SEEKING_NoFlush)) { - pthread_mutex_lock(&parser->mutex); - parser->flushing = false; - pthread_mutex_unlock(&parser->mutex); + unix_funcs->wg_parser_end_flush(filter->wg_parser); for (i = 0; i < filter->source_count; ++i) { diff --git a/dlls/winegstreamer/wg_parser.c b/dlls/winegstreamer/wg_parser.c index b3f8eff43ad..bb1d6188a8b 100644 --- a/dlls/winegstreamer/wg_parser.c +++ b/dlls/winegstreamer/wg_parser.c @@ -327,6 +327,28 @@ static struct wg_parser_stream * CDECL wg_parser_get_stream(struct wg_parser *pa return parser->streams[index]; } +static void CDECL wg_parser_begin_flush(struct wg_parser *parser) +{ + unsigned int i; + + pthread_mutex_lock(&parser->mutex); + parser->flushing = true; + pthread_mutex_unlock(&parser->mutex); + + for (i = 0; i < parser->stream_count; ++i) + { + if (parser->streams[i]->enabled) + pthread_cond_signal(&parser->streams[i]->event_cond); + } +} + +static void CDECL wg_parser_end_flush(struct wg_parser *parser) +{ + pthread_mutex_lock(&parser->mutex); + parser->flushing = false; + pthread_mutex_unlock(&parser->mutex); +} + static void CDECL wg_parser_stream_get_preferred_format(struct wg_parser_stream *stream, struct wg_format *format) { *format = stream->preferred_format; @@ -1520,6 +1542,9 @@ static const struct unix_funcs funcs = wg_parser_connect, wg_parser_disconnect, + wg_parser_begin_flush, + wg_parser_end_flush, + wg_parser_get_stream_count, wg_parser_get_stream,