From patchwork Mon Dec 12 05:00:16 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matt Oliver X-Patchwork-Id: 1763 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.65.86 with SMTP id o83csp1483154vsa; Sun, 11 Dec 2016 21:00:29 -0800 (PST) X-Received: by 10.28.62.77 with SMTP id l74mr7100817wma.37.1481518829186; Sun, 11 Dec 2016 21:00:29 -0800 (PST) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id y84si26909335wmg.11.2016.12.11.21.00.28; Sun, 11 Dec 2016 21:00:29 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 53F07689EC8; Mon, 12 Dec 2016 07:00:21 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-io0-f194.google.com (mail-io0-f194.google.com [209.85.223.194]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 3D0E3689814 for ; Mon, 12 Dec 2016 07:00:14 +0200 (EET) Received: by mail-io0-f194.google.com with SMTP id b194so19311514ioa.3 for ; Sun, 11 Dec 2016 21:00:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=N3U0IghS8vdgPq2KjGLdHpobzKCo2uwCynlc7b1gIlY=; b=TTWuEj/ioN09Miy6Bsht3ZYSCx9Ys9C5bZ7OVEuA6SbEt6VTtuXs+oUtOKODp9RDYN eGy8uM47GlP4I/dqOWUc5qOiIEY1ANqzpIupJoLANM9Dv2iW+JpBjpi0b6Q0aaUiU2u3 oZmb2w1+Vj83FP817K5RI2ScxaiOee5prp1NzuGG1ggmSRglZkCqJj5IJ0pMvlQZ4Qbo iisveli3MRGpiThjoxPu6IxmwfEVhxgAuaj6hRxtvRt+hYj04oqZf1Wo3bO8WV5/YU0B 5qjYK5QPKTHaLHCILpw3cNrqse65VQyPHFzkHDbIhyN+GPvA1gevElJfFIcZRhxT+iMj y6+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=N3U0IghS8vdgPq2KjGLdHpobzKCo2uwCynlc7b1gIlY=; b=h50M3ikAj1cl/S3lByc2g7xz4uyWC6Fn8Qt9jkaEfUFYrr40p2zTqRoOR8nvvGXVIt bvHAn7UCfdfAEv6lHfcPZ3SyED/dudIpM6CLMic97/eR6WmBBz6c6J6rbsjRKSRbT+cR TX/hTsDECLrUSg6nyXuoeBhFGUFsALEuGcUtI1nNYHp91OARC+L+ohx2+t7J/WTofWWI dgSo6jU9nI35wJskICJtTKck6Jj8yog0BXUcLbMcSiATahtL3LK1cmH0ah+uZe46/7Sf SvmekEVOr4cuynEr0hNXkhIlcfpL6XRyqadIr/t7fODy5mmaXHllmFQt9lhsz+YtDNJq 5a0A== X-Gm-Message-State: AKaTC00C33SR4LclcFppYB5C5s2V4kgN9lT9M/sah/77KPhrnBdPEzwFuN9HaTHHj73z6XjyGFQ4NQl6b//+IQ== X-Received: by 10.36.204.9 with SMTP id x9mr8143216itf.123.1481518817346; Sun, 11 Dec 2016 21:00:17 -0800 (PST) MIME-Version: 1.0 Received: by 10.36.80.144 with HTTP; Sun, 11 Dec 2016 21:00:16 -0800 (PST) In-Reply-To: References: <20161207174933.GA3935616@phare.normalesup.org> From: Matt Oliver Date: Mon, 12 Dec 2016 16:00:16 +1100 Message-ID: To: FFmpeg development discussions and patches X-Content-Filtered-By: Mailman/MimeDel 2.1.20 Subject: Re: [FFmpeg-devel] [PATCH 3/3] avformat/udp: Enable FIFO when using windows sockets. X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" --- libavformat/udp.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) av_log(h, AV_LOG_ERROR, "pthread_join(): %s\n", strerror(ret)); 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)