From: Santino Mazza smazza@codeweavers.com
First we set the EOS state, so the wait_parser_stream_buffer function doesn't call pthread_cond_wait again. Then we must call pthread_cond_signal to make sure that no one is waiting for it, if we don't do that, there is the possibility of hanging wg_parser_disconnect at the free_stream call, because pthread_cond_destroy will hang when the cond object is being waited by other threads.
Specifically this helps to fix a hang in some applications, specially Unreal Engine games when changing sources too fast in a MediaPlayer. --- dlls/winegstreamer/wg_parser.c | 2 ++ 1 file changed, 2 insertions(+)
diff --git a/dlls/winegstreamer/wg_parser.c b/dlls/winegstreamer/wg_parser.c index ef274b1dc27..b99ef9dbe31 100644 --- a/dlls/winegstreamer/wg_parser.c +++ b/dlls/winegstreamer/wg_parser.c @@ -1708,6 +1708,8 @@ static NTSTATUS wg_parser_disconnect(void *args) for (i = 0; i < parser->stream_count; ++i) { parser->streams[i]->flushing = true; + parser->streams[i]->eos = true; + pthread_cond_signal(&parser->streams[i]->event_cond); pthread_cond_signal(&parser->streams[i]->event_empty_cond); } pthread_mutex_unlock(&parser->mutex);