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 5C1F442762 for ; Wed, 30 Mar 2022 12:20:55 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 82D4268B284; Wed, 30 Mar 2022 15:20:02 +0300 (EEST) Received: from mail-lf1-f42.google.com (mail-lf1-f42.google.com [209.85.167.42]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 6709B68B280 for ; Wed, 30 Mar 2022 15:20:00 +0300 (EEST) Received: by mail-lf1-f42.google.com with SMTP id bq24so19522266lfb.5 for ; Wed, 30 Mar 2022 05:20:00 -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=NXrAkBxWGY5TrlVzdjwnIB6LUAWzaS/kf01BrfZeLSwOdF/zd3Dz/3wxWOtAoJxJHa dhJBxTvhXIu38AfTi4bGE+0ElKJkXK4Gg8QIJcQ5bBDderTLpdXdTxvpHJfDHgGS/tub ON67nwhWKTDFP4KbTjJWXBcfY78t+piWerVxEjHmuOLJR/fGuXbkZcqkNHpg3fluw/LJ sZL97lzaKlLzYl9tLpos29Uwa2dIrMZHU60MO//MbFlk51+j4tqy5oKHTfFd2Ii+rkxl 4il/1tirNw06nnp1l2J1cOUTMi5lXFDLYx/4Y1KR9kuVDYZIRiU3CNnK7dQFdXFKbsKH wYlw== 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=n8hVslHkkXBawOAlhn2O+s9v6i2VftRt1DZ3qEwOR2g9uyU0OkbzEHWPF7g7HwJPgD +r8bkedMRng/C81fO0qvtgrrgz1LMB0yNldw7gJjzFPcTW9rfHime6W6cpQTFS8/coGg dxr52FO3qeNF2VHlRaGnwZD1oEGVOJV8Wd440sDeUGQLnYWkMd0BLBKSyU6IWVbvshv+ lviggFb8XYp+adeU+NPkzkvZ6Vp5Dh8qfFB8wUBHBD1DyBk3yeQcL+JAflYNmX3Jr06o CiwdkBWwBCPGxZADJZlLZ1Oy4dzu3pkaJjwUrHAAGxyJ3+YVFaWetmBZKImbXjMTGfrj oNEQ== X-Gm-Message-State: AOAM532TldLAVhxRelhGeV58cm3srts2iOlxuUGwkFI5I++qRCbDHjpx spOvSP7SU8FH96ZW7RQO4J1rIyhqpyY= X-Google-Smtp-Source: ABdhPJxEQzxd23uc0fH6fLVT2w4sB2U1AbnlYZ8Z1th6X54yezoIrgePiTPaPXeXfWLzO3qsx3WjBQ== X-Received: by 2002:a05:6512:555:b0:44a:a75c:885c with SMTP id h21-20020a056512055500b0044aa75c885cmr6508200lfl.80.1648642798721; Wed, 30 Mar 2022 05:19:58 -0700 (PDT) Received: from localhost.localdomain (deedock.humlab.lu.se. [130.235.135.183]) by smtp.gmail.com with ESMTPSA id g36-20020a0565123ba400b0044a2a1ccd99sm2319993lfv.20.2022.03.30.05.19.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Mar 2022 05:19:58 -0700 (PDT) From: Diederick Niehorster To: ffmpeg-devel@ffmpeg.org Date: Wed, 30 Mar 2022 14:18:00 +0200 Message-Id: <20220330121806.822-16-dcnieho@gmail.com> X-Mailer: git-send-email 2.28.0.windows.1 In-Reply-To: <20220330121806.822-1-dcnieho@gmail.com> References: <20220330121806.822-1-dcnieho@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v5 15/21] 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".