From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id E831F429D9 for ; Sun, 10 Jul 2022 18:43:20 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 9E16C68B93A; Sun, 10 Jul 2022 21:43:17 +0300 (EEST) Received: from iq.passwd.hu (iq.passwd.hu [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 689F168B8C4 for ; Sun, 10 Jul 2022 21:43:11 +0300 (EEST) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id CAEA8E75C9; Sun, 10 Jul 2022 20:43:10 +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 uCZTzop_v8kD; Sun, 10 Jul 2022 20:42:43 +0200 (CEST) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 2549FE74EB; Sun, 10 Jul 2022 20:42:43 +0200 (CEST) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Sun, 10 Jul 2022 20:42:37 +0200 Message-Id: <20220710184237.4435-1-cus@passwd.hu> X-Mailer: git-send-email 2.35.3 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] avdevice/avdevice: fix return value of avdevice_list_devices() X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: According to API docs avdevice_list_devices(), avdevice_list_input_sources() and avdevice_list_input_sinks() should return the number of autodetected devices on success. This is redundant with AVDeviceInfoList->nb_devices so it was not noticed earlier that none of the underlying device list functions work like that. Let's fix it in generic code to make it in line with the API docs. Fixes ticket #9820. Signed-off-by: Marton Balint --- libavdevice/avdevice.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libavdevice/avdevice.c b/libavdevice/avdevice.c index b4fb272eb6..58996404b3 100644 --- a/libavdevice/avdevice.c +++ b/libavdevice/avdevice.c @@ -75,9 +75,11 @@ int avdevice_list_devices(AVFormatContext *s, AVDeviceInfoList **device_list) ret = s->oformat->get_device_list(s, *device_list); else ret = s->iformat->get_device_list(s, *device_list); - if (ret < 0) + if (ret < 0) { avdevice_free_list_devices(device_list); - return ret; + return ret; + } + return (*device_list)->nb_devices; } static int list_devices_for_context(AVFormatContext *s, AVDictionary *options, -- 2.35.3 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".