Commit 6613db97 authored by Ramiro Polla's avatar Ramiro Polla Committed by Stefano Sabatini

dshow: remove filters from graph before releasing them

Signed-off-by: 's avatarStefano Sabatini <stefasab@gmail.com>
parent a1644f62
...@@ -112,6 +112,22 @@ dshow_read_close(AVFormatContext *s) ...@@ -112,6 +112,22 @@ dshow_read_close(AVFormatContext *s)
IMediaControl_Release(ctx->control); IMediaControl_Release(ctx->control);
} }
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)
if (IGraphBuilder_RemoveFilter(ctx->graph, f) == S_OK)
IEnumFilters_Reset(fenum); /* When a filter is removed,
* the list must be reset. */
IEnumFilters_Release(fenum);
}
IGraphBuilder_Release(ctx->graph);
}
if (ctx->capture_pin[VideoDevice]) if (ctx->capture_pin[VideoDevice])
libAVPin_Release(ctx->capture_pin[VideoDevice]); libAVPin_Release(ctx->capture_pin[VideoDevice]);
if (ctx->capture_pin[AudioDevice]) if (ctx->capture_pin[AudioDevice])
...@@ -130,22 +146,6 @@ dshow_read_close(AVFormatContext *s) ...@@ -130,22 +146,6 @@ dshow_read_close(AVFormatContext *s)
if (ctx->device_filter[AudioDevice]) if (ctx->device_filter[AudioDevice])
IBaseFilter_Release(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)
if (IGraphBuilder_RemoveFilter(ctx->graph, f) == S_OK)
IEnumFilters_Reset(fenum); /* When a filter is removed,
* the list must be reset. */
IEnumFilters_Release(fenum);
}
IGraphBuilder_Release(ctx->graph);
}
if (ctx->device_name[0]) if (ctx->device_name[0])
av_free(ctx->device_name[0]); av_free(ctx->device_name[0]);
if (ctx->device_name[1]) if (ctx->device_name[1])
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment