summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorMichael Smith <msmith@xiph.org>2008-08-13 21:58:08 +0000
committerMichael Smith <msmith@xiph.org>2008-08-13 21:58:08 +0000
commitcbc51271903c1e88b142b7d8de4e3fb558009fcc (patch)
treec03bd80cc8e5ed09e47ada4ae7d88a3373be5679 /sys
parent85b99b9077b0c3f57cd6dac0c00123ac9d487791 (diff)
sys/: Initialise COM with default flags.
Original commit message from CVS: * sys/dshowdecwrapper/gstdshowaudiodec.c: * sys/dshowdecwrapper/gstdshowaudiodec.h: * sys/dshowdecwrapper/gstdshowvideodec.c: * sys/dshowdecwrapper/gstdshowvideodec.h: * sys/dshowvideosink/dshowvideosink.cpp: * sys/dshowvideosink/dshowvideosink.h: Initialise COM with default flags. Only deinitialise if the initialisation was successful.
Diffstat (limited to 'sys')
-rw-r--r--sys/dshowdecwrapper/gstdshowaudiodec.c18
-rw-r--r--sys/dshowdecwrapper/gstdshowaudiodec.h2
-rw-r--r--sys/dshowdecwrapper/gstdshowvideodec.c19
-rw-r--r--sys/dshowdecwrapper/gstdshowvideodec.h2
-rw-r--r--sys/dshowvideosink/dshowvideosink.cpp11
-rw-r--r--sys/dshowvideosink/dshowvideosink.h2
6 files changed, 44 insertions, 10 deletions
diff --git a/sys/dshowdecwrapper/gstdshowaudiodec.c b/sys/dshowdecwrapper/gstdshowaudiodec.c
index d5b5d7fd0..e436beb8c 100644
--- a/sys/dshowdecwrapper/gstdshowaudiodec.c
+++ b/sys/dshowdecwrapper/gstdshowaudiodec.c
@@ -275,6 +275,7 @@ gst_dshowaudiodec_init (GstDshowAudioDec * adec,
GstDshowAudioDecClass * adec_class)
{
GstElementClass *element_class = GST_ELEMENT_GET_CLASS (adec);
+ HRESULT hr;
/* setup pads */
adec->sinkpad =
@@ -310,7 +311,10 @@ gst_dshowaudiodec_init (GstDshowAudioDec * adec,
adec->last_ret = GST_FLOW_OK;
- CoInitializeEx (NULL, COINIT_MULTITHREADED);
+ hr = CoInitialize (0);
+ if (SUCCEEDED (hr)) {
+ adec->comInitialized = TRUE;
+ }
}
static void
@@ -328,7 +332,10 @@ gst_dshowaudiodec_dispose (GObject * object)
adec->codec_data = NULL;
}
- CoUninitialize ();
+ if (adec->comInitialized) {
+ CoUninitialize ();
+ adec->comInitialized = FALSE;
+ }
G_OBJECT_CLASS (parent_class)->dispose (object);
}
@@ -1141,11 +1148,12 @@ dshow_adec_register (GstPlugin * plugin)
(GInstanceInitFunc) gst_dshowaudiodec_init,
};
gint i;
+ HRESULT hr;
GST_DEBUG_CATEGORY_INIT (dshowaudiodec_debug, "dshowaudiodec", 0,
"Directshow filter audio decoder");
- CoInitializeEx (NULL, COINIT_MULTITHREADED);
+ hr = CoInitialize (0);
for (i = 0; i < sizeof (audio_dec_codecs) / sizeof (CodecEntry); i++) {
GType type;
@@ -1175,6 +1183,8 @@ dshow_adec_register (GstPlugin * plugin)
}
}
- CoUninitialize ();
+ if (SUCCEEDED (hr))
+ CoUninitialize ();
+
return TRUE;
}
diff --git a/sys/dshowdecwrapper/gstdshowaudiodec.h b/sys/dshowdecwrapper/gstdshowaudiodec.h
index d667aa469..732e636d4 100644
--- a/sys/dshowdecwrapper/gstdshowaudiodec.h
+++ b/sys/dshowdecwrapper/gstdshowaudiodec.h
@@ -98,6 +98,8 @@ struct _GstDshowAudioDec
/* timestamp of the next buffer */
GstClockTime timestamp;
+
+ gboolean comInitialized;
};
struct _GstDshowAudioDecClass
diff --git a/sys/dshowdecwrapper/gstdshowvideodec.c b/sys/dshowdecwrapper/gstdshowvideodec.c
index 812b32c44..3c95771d1 100644
--- a/sys/dshowdecwrapper/gstdshowvideodec.c
+++ b/sys/dshowdecwrapper/gstdshowvideodec.c
@@ -306,6 +306,7 @@ gst_dshowvideodec_init (GstDshowVideoDec * vdec,
GstDshowVideoDecClass * vdec_class)
{
GstElementClass *element_class = GST_ELEMENT_GET_CLASS (vdec);
+ HRESULT hr;
/* setup pads */
vdec->sinkpad =
@@ -337,7 +338,10 @@ gst_dshowvideodec_init (GstDshowVideoDec * vdec,
vdec->srccaps = NULL;
vdec->segment = gst_segment_new ();
- CoInitializeEx (NULL, COINIT_MULTITHREADED);
+ hr = CoInitialize (0);
+ if (SUCCEEDED (hr)) {
+ vdec->comInitialized = TRUE;
+ }
}
static void
@@ -350,7 +354,10 @@ gst_dshowvideodec_dispose (GObject * object)
vdec->segment = NULL;
}
- CoUninitialize ();
+ if (vdec->comInitialized) {
+ CoUninitialize ();
+ vdec->comInitialized = FALSE;
+ }
G_OBJECT_CLASS (parent_class)->dispose (object);
}
@@ -1099,11 +1106,13 @@ dshow_vdec_register (GstPlugin * plugin)
(GInstanceInitFunc) gst_dshowvideodec_init,
};
gint i;
+ HRESULT hr;
GST_DEBUG_CATEGORY_INIT (dshowvideodec_debug, "dshowvideodec", 0,
"Directshow filter video decoder");
- CoInitializeEx (NULL, COINIT_MULTITHREADED);
+ hr = CoInitialize (0);
+
for (i = 0; i < sizeof (video_dec_codecs) / sizeof (CodecEntry); i++) {
GType type;
@@ -1133,6 +1142,8 @@ dshow_vdec_register (GstPlugin * plugin)
}
}
- CoUninitialize ();
+ if (SUCCEEDED (hr))
+ CoUninitialize ();
+
return TRUE;
}
diff --git a/sys/dshowdecwrapper/gstdshowvideodec.h b/sys/dshowdecwrapper/gstdshowvideodec.h
index 0989dabc4..0ab7a5d71 100644
--- a/sys/dshowdecwrapper/gstdshowvideodec.h
+++ b/sys/dshowdecwrapper/gstdshowvideodec.h
@@ -92,6 +92,8 @@ struct _GstDshowVideoDec
/* current segment */
GstSegment *segment;
+
+ gboolean comInitialized;
};
struct _GstDshowVideoDecClass
diff --git a/sys/dshowvideosink/dshowvideosink.cpp b/sys/dshowvideosink/dshowvideosink.cpp
index b191c98b0..788dbdd5c 100644
--- a/sys/dshowvideosink/dshowvideosink.cpp
+++ b/sys/dshowvideosink/dshowvideosink.cpp
@@ -211,9 +211,13 @@ gst_dshowvideosink_clear (GstDshowVideoSink *sink)
static void
gst_dshowvideosink_init (GstDshowVideoSink * sink, GstDshowVideoSinkClass * klass)
{
+ HRESULT hr;
+
gst_dshowvideosink_clear (sink);
- CoInitializeEx (NULL, COINIT_MULTITHREADED);
+ hr = CoInitialize (0);
+ if (SUCCEEDED(hr))
+ sink->comInitialized = TRUE;
/* TODO: Copied from GstVideoSink; should we use that as base class? */
/* 20ms is more than enough, 80-130ms is noticable */
@@ -229,7 +233,10 @@ gst_dshowvideosink_finalize (GObject * gobject)
if (sink->preferredrenderer)
g_free (sink->preferredrenderer);
- CoUninitialize ();
+ if (sink->comInitialized) {
+ CoUninitialize ();
+ sink->comInitialized = FALSE;
+ }
G_OBJECT_CLASS (parent_class)->finalize (gobject);
}
diff --git a/sys/dshowvideosink/dshowvideosink.h b/sys/dshowvideosink/dshowvideosink.h
index 69ac28e2c..fd03c2b7e 100644
--- a/sys/dshowvideosink/dshowvideosink.h
+++ b/sys/dshowvideosink/dshowvideosink.h
@@ -91,6 +91,8 @@ struct _GstDshowVideoSink
/* If we use an app-supplied window, we need to hook its WNDPROC */
WNDPROC prevWndProc;
+
+ gboolean comInitialized;
};
struct _GstDshowVideoSinkClass