Signed-off-by: Matt Oliver <[email protected]> --- libavformat/udp.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-)
diff --git a/libavformat/udp.c b/libavformat/udp.c
index f8c861d..0e4766f 100644
--- a/libavformat/udp.c
+++ b/libavformat/udp.c
@@ -64,6 +64,14 @@
#define HAVE_PTHREAD_CANCEL 0
#endif
+#if !HAVE_PTHREAD_CANCEL && (HAVE_THREADS && HAVE_WINSOCK2_H)
+/* Winsock2 recv function can be unblocked by shutting down and closing
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,14 @@ 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_PTHREAD_CANCEL && (HAVE_THREADS && HAVE_WINSOCK2_H)
+ closesocket(s->udp_fd);
+ s->udp_fd = INVALID_SOCKET;
+# 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));
@@ -1153,7 +1167,8 @@ static int udp_close(URLContext *h)
pthread_cond_destroy(&s->cond);
}
#endif
- closesocket(s->udp_fd);
+ if(s->udp_fd != INVALID_SOCKET)
+ closesocket(s->udp_fd);
av_fifo_freep(&s->fifo);
return 0;
}
--
2.10.2.windows.1
0003-avformat-udp-Enable-FIFO-when-using-windows-sockets.patch
Description: Binary data
_______________________________________________ ffmpeg-devel mailing list [email protected] http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
