Module: wine Branch: master Commit: ed3ed4d8abbea862c990c25c87143e86bf6be85d URL: https://source.winehq.org/git/wine.git/?a=commit;h=ed3ed4d8abbea862c990c25c8...
Author: Zebediah Figura z.figura12@gmail.com Date: Wed Jan 27 16:18:47 2021 -0600
winegstreamer: Make push_data() into a POSIX thread.
Signed-off-by: Zebediah Figura z.figura12@gmail.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/winegstreamer/gstdemux.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-)
diff --git a/dlls/winegstreamer/gstdemux.c b/dlls/winegstreamer/gstdemux.c index e73693de939..a4d49c75a1b 100644 --- a/dlls/winegstreamer/gstdemux.c +++ b/dlls/winegstreamer/gstdemux.c @@ -74,7 +74,7 @@ struct parser pthread_cond_t init_cond; bool no_more_pads, has_duration, error;
- HANDLE push_thread; + pthread_t push_thread;
HANDLE read_thread; pthread_cond_t read_cond, read_done_cond; @@ -823,7 +823,7 @@ static gboolean event_sink(GstPad *pad, GstObject *parent, GstEvent *event)
static GstFlowReturn request_buffer_src(GstPad *pad, GstObject *parent, guint64 offset, guint size, GstBuffer **buffer);
-static DWORD CALLBACK push_data(LPVOID iface) +static void *push_data(void *iface) { struct parser *This = iface; GstBuffer *buffer; @@ -834,7 +834,7 @@ static DWORD CALLBACK push_data(LPVOID iface) if (!(buffer = gst_buffer_new_allocate(NULL, 16384, NULL))) { GST_ERROR("Failed to allocate memory."); - return 0; + return NULL; }
maxlen = This->stop ? This->stop : This->filesize; @@ -869,7 +869,7 @@ static DWORD CALLBACK push_data(LPVOID iface)
GST_DEBUG("Stopping push thread.");
- return 0; + return NULL; }
static GstFlowReturn got_data_sink(GstPad *pad, GstObject *parent, GstBuffer *buffer) @@ -1426,16 +1426,22 @@ static gboolean activate_push(GstPad *pad, gboolean activate) TRACE("Deactivating\n"); IAsyncReader_BeginFlush(This->reader); if (This->push_thread) { - WaitForSingleObject(This->push_thread, -1); - CloseHandle(This->push_thread); - This->push_thread = NULL; + pthread_join(This->push_thread, NULL); + This->push_thread = 0; } IAsyncReader_EndFlush(This->reader); if (This->filter.state == State_Stopped) This->nextofs = This->start; } else if (!This->push_thread) { + int ret; + TRACE("Activating\n"); - This->push_thread = CreateThread(NULL, 0, push_data, This, 0, NULL); + if ((ret = pthread_create(&This->push_thread, NULL, push_data, This))) + { + GST_ERROR("Failed to create push thread: %s", strerror(errno)); + This->push_thread = 0; + return FALSE; + } } LeaveCriticalSection(&This->filter.filter_cs); return TRUE;