Last active
December 16, 2016 01:55
-
-
Save Sibras/6fef0e4a57e44576ed0929c913c7e9d5 to your computer and use it in GitHub Desktop.
[PATCH 3/3] avformat/udp: Enable FIFO when using windows sockets.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From b548dbc7de4e17c500658d263f152013290859cb Mon Sep 17 00:00:00 2001 | |
From: Matt Oliver <protogonoi@gmail.com> | |
Date: Fri, 16 Dec 2016 12:53:28 +1100 | |
Subject: [PATCH 3/3] avformat/udp: Enable FIFO when using windows sockets. | |
Signed-off-by: Matt Oliver <protogonoi@gmail.com> | |
--- | |
libavformat/udp.c | 15 ++++++++++++++- | |
1 file changed, 14 insertions(+), 1 deletion(-) | |
diff --git a/libavformat/udp.c b/libavformat/udp.c | |
index f8c861d..5b8a58c 100644 | |
--- a/libavformat/udp.c | |
+++ b/libavformat/udp.c | |
@@ -64,6 +64,14 @@ | |
#define HAVE_PTHREAD_CANCEL 0 | |
#endif | |
+#if HAVE_THREADS && HAVE_WINSOCK2_H | |
+/* Winsock2 recv function can be unblocked by shutting down the socket */ | |
+#define pthread_setcancelstate(x, y) | |
+#define pthread_cancel | |
+#undef HAVE_PTHREAD_CANCEL | |
+#define HAVE_PTHREAD_CANCEL 1 | |
+#endif | |
+ | |
#if HAVE_PTHREAD_CANCEL | |
#include "libavutil/thread.h" | |
#endif | |
@@ -1144,8 +1152,13 @@ static int udp_close(URLContext *h) | |
if (s->thread_started) { | |
int ret; | |
// Cancel only read, as write has been signaled as success to the user | |
- if (h->flags & AVIO_FLAG_READ) | |
+ if (h->flags & AVIO_FLAG_READ) { | |
+# if HAVE_THREADS && HAVE_WINSOCK2_H | |
+ shutdown(s->udp_fd, SD_BOTH); | |
+# else | |
pthread_cancel(s->circular_buffer_thread); | |
+# endif | |
+ } | |
ret = pthread_join(s->circular_buffer_thread, NULL); | |
if (ret != 0) | |
av_log(h, AV_LOG_ERROR, "pthread_join(): %s\n", strerror(ret)); | |
-- | |
2.10.2.windows.1 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment