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 809384107C for ; Fri, 25 Mar 2022 14:14:22 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id B5EE268B2B0; Fri, 25 Mar 2022 16:12:56 +0200 (EET) Received: from mail-lj1-f177.google.com (mail-lj1-f177.google.com [209.85.208.177]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4ADF868B2AA for ; Fri, 25 Mar 2022 16:12:55 +0200 (EET) Received: by mail-lj1-f177.google.com with SMTP id q14so10453154ljc.12 for ; Fri, 25 Mar 2022 07:12:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=NK/QrJEeth1MSuzhPObWDUazu7iR/OBn1N+cSzfeM/U=; b=l5pR1FV2/pro4YAxwyBCkL3T3Qr+iFbNgw4V3mZ/NklJ/LtwAe7JMsId1rBR9lgUU4 ikOtPmRQXRMK976g5TdeOcV7Em26RkuY9B6xGBfJ8Toh7Uqyb3wJK9ZWgmD8M0c5AABC 1UP5q/c54prESP7pkqNA1HB04h7Gh1CVOIjd2Z9PblI4300KmOAwjQbAnzGxotIAYKxP DIoLl5iytzinR5NUDRdseSSj22vfxOI/6JY0jxE7f0GXKastngPZtr+8KQW7bjr3K1+R PESo8db2KLB9yp54frz2wjdsgQpVrJv3r34gQjgcKo4FKFJPkwoeN9OUM6T8bPWb28PC gr3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=NK/QrJEeth1MSuzhPObWDUazu7iR/OBn1N+cSzfeM/U=; b=zAduQjVMChPxPphiHETr091xd43tWRyAlOmCUDMahsOYDQRwLGkHhvWY/M4fn7bK8V P/v0SBiiw3w+9FndGA7gOYTDtv4TPkHNPuFWiG2+D7Fkpy6kSGCaEgoChELB5SibLXvI 3T5U7hUVa+Xg6occD/LhYhWwxCZ52T84IlZj7hoaKuIt1C7wWruDu/kqCL8YjImyRqwK wwPLN1bIrGlHD1P63N6Oehd2wTA2Jkp9R4bo+JEXj/VK4heb76IZJ/9WRveTOwj30fg2 2gomxvwgz16bHTY6ULF2SlaBoaucmE7Y52qoeXsYcP0Ig7MaglJuIeTDY1jQgRBiyWf6 0/lg== X-Gm-Message-State: AOAM531Yl7tEbw0xDoTyq6peBvCqDkp34h+uNdO0NLK7XJnW37E3XMya asOcfPd3S5klbGVa/1a4/ZqH+wnZ3Ss= X-Google-Smtp-Source: ABdhPJzP651Izn4+sgv6r87hUsSj07zKmhaqmwtdme7sBRmC6nAtVISNf0JpQuyfLhGUIYg+fhwFvg== X-Received: by 2002:a2e:96c6:0:b0:249:863c:5b2a with SMTP id d6-20020a2e96c6000000b00249863c5b2amr8039956ljj.103.1648217574135; Fri, 25 Mar 2022 07:12:54 -0700 (PDT) Received: from localhost.localdomain (deedock.humlab.lu.se. [130.235.135.183]) by smtp.gmail.com with ESMTPSA id g27-20020a2eb5db000000b002498222c8dasm680975ljn.65.2022.03.25.07.12.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Mar 2022 07:12:53 -0700 (PDT) From: Diederick Niehorster To: ffmpeg-devel@ffmpeg.org Date: Fri, 25 Mar 2022 15:10:35 +0100 Message-Id: <20220325141041.1748-17-dcnieho@gmail.com> X-Mailer: git-send-email 2.28.0.windows.1 In-Reply-To: <20220325141041.1748-1-dcnieho@gmail.com> References: <20220325141041.1748-1-dcnieho@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v4 16/22] avdevice/dshow: when closing, set context fields back to zero 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: Diederick Niehorster 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: After the avdevice capabilities API is implemented, the format context may be reused after querying device capabilities in a later avformat_open_input call. To enable this reuse, after releasing resources, make sure to also set the corresponding pointers back to NULL. This correctly indicates their state after cleanup. Signed-off-by: Diederick Niehorster --- libavdevice/dshow.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/libavdevice/dshow.c b/libavdevice/dshow.c index d35224beb5..0d5f731030 100644 --- a/libavdevice/dshow.c +++ b/libavdevice/dshow.c @@ -264,14 +264,18 @@ dshow_read_close(AVFormatContext *s) ICaptureGraphBuilder2_Release(ctx->graph_builder2[VideoDevice]); if (ctx->graph_builder2[AudioDevice]) ICaptureGraphBuilder2_Release(ctx->graph_builder2[AudioDevice]); + ctx->graph_builder2[0] = NULL; + ctx->graph_builder2[1] = NULL; if (ctx->control) { IMediaControl_Stop(ctx->control); IMediaControl_Release(ctx->control); } + ctx->control = NULL; if (ctx->media_event) IMediaEvent_Release(ctx->media_event); + ctx->media_event = NULL; if (ctx->graph) { IEnumFilters *fenum; @@ -289,25 +293,34 @@ dshow_read_close(AVFormatContext *s) IEnumFilters_Release(fenum); } IGraphBuilder_Release(ctx->graph); + ctx->graph = NULL; } if (ctx->capture_pin[VideoDevice]) ff_dshow_pin_Release(ctx->capture_pin[VideoDevice]); if (ctx->capture_pin[AudioDevice]) ff_dshow_pin_Release(ctx->capture_pin[AudioDevice]); + ctx->capture_pin[0] = NULL; + ctx->capture_pin[1] = NULL; if (ctx->capture_filter[VideoDevice]) ff_dshow_filter_Release(ctx->capture_filter[VideoDevice]); if (ctx->capture_filter[AudioDevice]) ff_dshow_filter_Release(ctx->capture_filter[AudioDevice]); + ctx->capture_filter[0] = NULL; + ctx->capture_filter[1] = NULL; if (ctx->device_pin[VideoDevice]) IPin_Release(ctx->device_pin[VideoDevice]); if (ctx->device_pin[AudioDevice]) IPin_Release(ctx->device_pin[AudioDevice]); + ctx->device_pin[0] = NULL; + ctx->device_pin[1] = NULL; if (ctx->device_filter[VideoDevice]) IBaseFilter_Release(ctx->device_filter[VideoDevice]); if (ctx->device_filter[AudioDevice]) IBaseFilter_Release(ctx->device_filter[AudioDevice]); + ctx->device_filter[0] = NULL; + ctx->device_filter[1] = NULL; av_freep(&ctx->device_name[0]); av_freep(&ctx->device_name[1]); @@ -316,10 +329,13 @@ dshow_read_close(AVFormatContext *s) if(ctx->mutex) CloseHandle(ctx->mutex); + ctx->mutex = NULL; if(ctx->event[0]) CloseHandle(ctx->event[0]); if(ctx->event[1]) CloseHandle(ctx->event[1]); + ctx->event[0] = NULL; + ctx->event[1] = NULL; pktl = ctx->pktl; while (pktl) { @@ -328,6 +344,7 @@ dshow_read_close(AVFormatContext *s) av_free(pktl); pktl = next; } + ctx->pktl = NULL; CoUninitialize(); -- 2.28.0.windows.1 _______________________________________________ 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".