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.
This commit is contained in:
Michael Smith 2008-08-13 21:58:08 +00:00
parent 85b99b9077
commit cbc5127190
7 changed files with 55 additions and 10 deletions

View file

@ -1,3 +1,14 @@
2008-08-13 Michael Smith <msmith@songbirdnest.com>
* 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.
2008-08-13 Wim Taymans <wim.taymans@collabora.co.uk>
* gst/rtpmanager/gstrtpbin.c: (gst_rtp_bin_associate),

View file

@ -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;
}

View file

@ -98,6 +98,8 @@ struct _GstDshowAudioDec
/* timestamp of the next buffer */
GstClockTime timestamp;
gboolean comInitialized;
};
struct _GstDshowAudioDecClass

View file

@ -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;
}

View file

@ -92,6 +92,8 @@ struct _GstDshowVideoDec
/* current segment */
GstSegment *segment;
gboolean comInitialized;
};
struct _GstDshowVideoDecClass

View file

@ -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);
}

View file

@ -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