--- libavformat/udp.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-)
diff --git a/libavformat/udp.c b/libavformat/udp.c index f8c861d..3cafb32 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 @@ -526,6 +534,8 @@ static void *circular_buffer_task_rx( void *_URLContext) goto end; } continue; + } else if (len == 0) { + goto end; } AV_WL32(s->tmp, len); @@ -1144,8 +1154,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)); --
0003-avformat-udp-Enable-FIFO-when-using-windows-sockets.patch
Description: Binary data
_______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel