[FFmpeg-devel] PATCH: dshow: don't add two instances of same device to graphs

Roger Pack rogerdpack2 at gmail.com
Fri Jun 17 22:05:28 CEST 2016


On 6/15/16, Clément Bœsch <u at pkh.me> wrote:
> On Wed, Jun 15, 2016 at 02:54:09AM -0600, Roger Pack wrote:
>> A handful of devices don't support this, and the rest work fine with it
>> :)
>>
>> -roger-
>
>> From e724d7f169bcae3217455cd88f9c023d275d367a Mon Sep 17 00:00:00 2001
>> From: rogerdpack <rogerpack2005 at gmail.com>
>> Date: Wed, 15 Jun 2016 02:17:11 -0600
>> Subject: [PATCH] dshow: don't add two instances of same device to graphs
>>
>> Signed-off-by: rogerdpack <rogerpack2005 at gmail.com>
>> ---
>>  libavdevice/dshow.c         | 37 ++++++++++++++++++++++++++++++-------
>>  libavdevice/dshow_capture.h |  2 ++
>>  2 files changed, 32 insertions(+), 7 deletions(-)
>>
>> diff --git a/libavdevice/dshow.c b/libavdevice/dshow.c
>> index 5f2cad7..e1ac855 100644
>> --- a/libavdevice/dshow.c
>> +++ b/libavdevice/dshow.c
>> @@ -108,6 +108,10 @@ dshow_read_close(AVFormatContext *s)
>>          av_freep(&ctx->device_name[0]);
>>      if (ctx->device_name[1])
>>          av_freep(&ctx->device_name[1]);
>
>> +    if (ctx->device_unique_name[0])
>> +        av_freep(&ctx->device_unique_name[0]);
>> +    if (ctx->device_unique_name[1])
>> +        av_freep(&ctx->device_unique_name[1]);
>
> I can't comment the rest of the patch, but please remove the ifs. They are,
> and always were, totally useless. Just like those above.

OK see also attached patch, to be applied after patch 1.
Thanks, will wait three days and if no objections, request these
patches be committed.
Cheers!
-------------- next part --------------
From 61e07cc85785345122832b1b5333412b5272c545 Mon Sep 17 00:00:00 2001
From: rogerdpack <rogerpack2005 at gmail.com>
Date: Fri, 17 Jun 2016 14:04:34 -0600
Subject: [PATCH 2/2] dshow: avoid duplicate NULL check before free

Signed-off-by: rogerdpack <rogerpack2005 at gmail.com>
---
 libavdevice/dshow.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/libavdevice/dshow.c b/libavdevice/dshow.c
index e1ac855..127e4c2 100644
--- a/libavdevice/dshow.c
+++ b/libavdevice/dshow.c
@@ -104,14 +104,10 @@ dshow_read_close(AVFormatContext *s)
     if (ctx->device_filter[AudioDevice])
         IBaseFilter_Release(ctx->device_filter[AudioDevice]);
 
-    if (ctx->device_name[0])
-        av_freep(&ctx->device_name[0]);
-    if (ctx->device_name[1])
-        av_freep(&ctx->device_name[1]);
-    if (ctx->device_unique_name[0])
-        av_freep(&ctx->device_unique_name[0]);
-    if (ctx->device_unique_name[1])
-        av_freep(&ctx->device_unique_name[1]);
+    av_freep(&ctx->device_name[0]);
+    av_freep(&ctx->device_name[1]);
+    av_freep(&ctx->device_unique_name[0]);
+    av_freep(&ctx->device_unique_name[1]);
 
     if(ctx->mutex)
         CloseHandle(ctx->mutex);
-- 
2.8.3.windows.1



More information about the ffmpeg-devel mailing list