[FFmpeg-devel] [PATCH 7/7] dshow: properly disconnect and remove filters from graph

Ramiro Polla ramiro.polla at gmail.com
Fri Sep 2 06:45:15 CEST 2011


---
 libavdevice/dshow.c |   18 ++++++++++++++----
 1 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/libavdevice/dshow.c b/libavdevice/dshow.c
index 133e7be..45d3f10 100644
--- a/libavdevice/dshow.c
+++ b/libavdevice/dshow.c
@@ -111,11 +111,7 @@ dshow_read_close(AVFormatContext *s)
         IMediaControl_Stop(ctx->control);
         IMediaControl_Release(ctx->control);
     }
-    if (ctx->graph)
-        IGraphBuilder_Release(ctx->graph);
 
-    /* FIXME remove filters from graph */
-    /* FIXME disconnect pins */
     if (ctx->capture_pin[VideoDevice])
         libAVPin_Release(ctx->capture_pin[VideoDevice]);
     if (ctx->capture_pin[AudioDevice])
@@ -134,6 +130,20 @@ dshow_read_close(AVFormatContext *s)
     if (ctx->device_filter[AudioDevice])
         IBaseFilter_Release(ctx->device_filter[AudioDevice]);
 
+    if (ctx->graph) {
+        IEnumFilters *fenum;
+        int r;
+        r = IGraphBuilder_EnumFilters(ctx->graph, &fenum);
+        if (r == S_OK) {
+            IBaseFilter *f;
+            IEnumFilters_Reset(fenum);
+            while (IEnumFilters_Next(fenum, 1, &f, NULL) == S_OK)
+                IGraphBuilder_RemoveFilter(ctx->graph, f);
+            IEnumFilters_Release(fenum);
+        }
+        IGraphBuilder_Release(ctx->graph);
+    }
+
     if (ctx->device_name[0])
         av_free(ctx->device_name[0]);
     if (ctx->device_name[1])
-- 
1.7.4.1



More information about the ffmpeg-devel mailing list