From patchwork Fri Sep 30 20:35:43 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 794 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.140.66 with SMTP id o63csp435026vsd; Fri, 30 Sep 2016 13:35:59 -0700 (PDT) X-Received: by 10.194.149.102 with SMTP id tz6mr8439891wjb.154.1475267759805; Fri, 30 Sep 2016 13:35:59 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id k1si10806238wjy.174.2016.09.30.13.35.58; Fri, 30 Sep 2016 13:35:59 -0700 (PDT) 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; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 71EB2689FD1; Fri, 30 Sep 2016 23:35:43 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from iq.passwd.hu (iq.passwd.hu [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4C664689DF9 for ; Fri, 30 Sep 2016 23:35:37 +0300 (EEST) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 4E41610176E; Fri, 30 Sep 2016 22:35:50 +0200 (CEST) X-Virus-Scanned: amavisd-new at passwd.hu Received: from iq.passwd.hu ([127.0.0.1]) by localhost (iq.passwd.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id jZROJOwueU90; Fri, 30 Sep 2016 22:35:49 +0200 (CEST) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id C5BB8100B9D; Fri, 30 Sep 2016 22:35:48 +0200 (CEST) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Fri, 30 Sep 2016 22:35:43 +0200 Message-Id: <1475267743-17200-1-git-send-email-cus@passwd.hu> X-Mailer: git-send-email 2.6.6 In-Reply-To: References: Subject: [FFmpeg-devel] [PATCH] lavd/openal: don't return zero sized packet if no samples are available 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 Cc: Marton Balint MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Signed-off-by: Marton Balint --- libavdevice/openal-dec.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/libavdevice/openal-dec.c b/libavdevice/openal-dec.c index 0647952..6eb0efe 100644 --- a/libavdevice/openal-dec.c +++ b/libavdevice/openal-dec.c @@ -187,9 +187,16 @@ static int read_packet(AVFormatContext* ctx, AVPacket *pkt) const char *error_msg; ALCint nb_samples; - /* Get number of samples available */ - alcGetIntegerv(ad->device, ALC_CAPTURE_SAMPLES, (ALCsizei) sizeof(ALCint), &nb_samples); - if (error = al_get_error(ad->device, &error_msg)) goto fail; + for (;;) { + /* Get number of samples available */ + alcGetIntegerv(ad->device, ALC_CAPTURE_SAMPLES, (ALCsizei) sizeof(ALCint), &nb_samples); + if (error = al_get_error(ad->device, &error_msg)) goto fail; + if (nb_samples > 0) + break; + if (ctx->flags & AVFMT_FLAG_NONBLOCK) + return AVERROR(EAGAIN); + av_usleep(1000); + } /* Create a packet of appropriate size */ if ((error = av_new_packet(pkt, nb_samples*ad->sample_step)) < 0)