Commit 83a9f29f authored by Ramiro Polla's avatar Ramiro Polla

dshow: call CoUninitialize() on dshow_read_close()

Every call to CoInitialize should have a matching CoUnititalize.

Based on patch by Don Moir <donmoir@comcast.net>.
parent 190f6135
...@@ -181,6 +181,8 @@ dshow_read_close(AVFormatContext *s) ...@@ -181,6 +181,8 @@ dshow_read_close(AVFormatContext *s)
pktl = next; pktl = next;
} }
CoUninitialize();
return 0; return 0;
} }
...@@ -793,7 +795,6 @@ dshow_add_device(AVFormatContext *avctx, ...@@ -793,7 +795,6 @@ dshow_add_device(AVFormatContext *avctx,
if (codec->codec_id == AV_CODEC_ID_NONE) { if (codec->codec_id == AV_CODEC_ID_NONE) {
av_log(avctx, AV_LOG_ERROR, "Unknown compression type. " av_log(avctx, AV_LOG_ERROR, "Unknown compression type. "
"Please report verbose (-v 9) debug information.\n"); "Please report verbose (-v 9) debug information.\n");
dshow_read_close(avctx);
return AVERROR_PATCHWELCOME; return AVERROR_PATCHWELCOME;
} }
codec->bits_per_coded_sample = bih->biBitCount; codec->bits_per_coded_sample = bih->biBitCount;
...@@ -883,6 +884,8 @@ static int dshow_read_header(AVFormatContext *avctx) ...@@ -883,6 +884,8 @@ static int dshow_read_header(AVFormatContext *avctx)
int ret = AVERROR(EIO); int ret = AVERROR(EIO);
int r; int r;
CoInitialize(0);
if (!ctx->list_devices && !parse_device_name(avctx)) { if (!ctx->list_devices && !parse_device_name(avctx)) {
av_log(avctx, AV_LOG_ERROR, "Malformed dshow input string.\n"); av_log(avctx, AV_LOG_ERROR, "Malformed dshow input string.\n");
goto error; goto error;
...@@ -906,8 +909,6 @@ static int dshow_read_header(AVFormatContext *avctx) ...@@ -906,8 +909,6 @@ static int dshow_read_header(AVFormatContext *avctx)
} }
} }
CoInitialize(0);
r = CoCreateInstance(&CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER, r = CoCreateInstance(&CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER,
&IID_IGraphBuilder, (void **) &graph); &IID_IGraphBuilder, (void **) &graph);
if (r != S_OK) { if (r != S_OK) {
...@@ -1007,12 +1008,12 @@ static int dshow_read_header(AVFormatContext *avctx) ...@@ -1007,12 +1008,12 @@ static int dshow_read_header(AVFormatContext *avctx)
error: error:
if (ret < 0)
dshow_read_close(avctx);
if (devenum) if (devenum)
ICreateDevEnum_Release(devenum); ICreateDevEnum_Release(devenum);
if (ret < 0)
dshow_read_close(avctx);
return ret; return ret;
} }
......
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