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> 2008-08-13 Wim Taymans <wim.taymans@collabora.co.uk>
* gst/rtpmanager/gstrtpbin.c: (gst_rtp_bin_associate), * gst/rtpmanager/gstrtpbin.c: (gst_rtp_bin_associate),

View File

@ -275,6 +275,7 @@ gst_dshowaudiodec_init (GstDshowAudioDec * adec,
GstDshowAudioDecClass * adec_class) GstDshowAudioDecClass * adec_class)
{ {
GstElementClass *element_class = GST_ELEMENT_GET_CLASS (adec); GstElementClass *element_class = GST_ELEMENT_GET_CLASS (adec);
HRESULT hr;
/* setup pads */ /* setup pads */
adec->sinkpad = adec->sinkpad =
@ -310,7 +311,10 @@ gst_dshowaudiodec_init (GstDshowAudioDec * adec,
adec->last_ret = GST_FLOW_OK; adec->last_ret = GST_FLOW_OK;
CoInitializeEx (NULL, COINIT_MULTITHREADED); hr = CoInitialize (0);
if (SUCCEEDED (hr)) {
adec->comInitialized = TRUE;
}
} }
static void static void
@ -328,7 +332,10 @@ gst_dshowaudiodec_dispose (GObject * object)
adec->codec_data = NULL; adec->codec_data = NULL;
} }
CoUninitialize (); if (adec->comInitialized) {
CoUninitialize ();
adec->comInitialized = FALSE;
}
G_OBJECT_CLASS (parent_class)->dispose (object); G_OBJECT_CLASS (parent_class)->dispose (object);
} }
@ -1141,11 +1148,12 @@ dshow_adec_register (GstPlugin * plugin)
(GInstanceInitFunc) gst_dshowaudiodec_init, (GInstanceInitFunc) gst_dshowaudiodec_init,
}; };
gint i; gint i;
HRESULT hr;
GST_DEBUG_CATEGORY_INIT (dshowaudiodec_debug, "dshowaudiodec", 0, GST_DEBUG_CATEGORY_INIT (dshowaudiodec_debug, "dshowaudiodec", 0,
"Directshow filter audio decoder"); "Directshow filter audio decoder");
CoInitializeEx (NULL, COINIT_MULTITHREADED); hr = CoInitialize (0);
for (i = 0; i < sizeof (audio_dec_codecs) / sizeof (CodecEntry); i++) { for (i = 0; i < sizeof (audio_dec_codecs) / sizeof (CodecEntry); i++) {
GType type; GType type;
@ -1175,6 +1183,8 @@ dshow_adec_register (GstPlugin * plugin)
} }
} }
CoUninitialize (); if (SUCCEEDED (hr))
CoUninitialize ();
return TRUE; return TRUE;
} }

View File

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

View File

@ -306,6 +306,7 @@ gst_dshowvideodec_init (GstDshowVideoDec * vdec,
GstDshowVideoDecClass * vdec_class) GstDshowVideoDecClass * vdec_class)
{ {
GstElementClass *element_class = GST_ELEMENT_GET_CLASS (vdec); GstElementClass *element_class = GST_ELEMENT_GET_CLASS (vdec);
HRESULT hr;
/* setup pads */ /* setup pads */
vdec->sinkpad = vdec->sinkpad =
@ -337,7 +338,10 @@ gst_dshowvideodec_init (GstDshowVideoDec * vdec,
vdec->srccaps = NULL; vdec->srccaps = NULL;
vdec->segment = gst_segment_new (); vdec->segment = gst_segment_new ();
CoInitializeEx (NULL, COINIT_MULTITHREADED); hr = CoInitialize (0);
if (SUCCEEDED (hr)) {
vdec->comInitialized = TRUE;
}
} }
static void static void
@ -350,7 +354,10 @@ gst_dshowvideodec_dispose (GObject * object)
vdec->segment = NULL; vdec->segment = NULL;
} }
CoUninitialize (); if (vdec->comInitialized) {
CoUninitialize ();
vdec->comInitialized = FALSE;
}
G_OBJECT_CLASS (parent_class)->dispose (object); G_OBJECT_CLASS (parent_class)->dispose (object);
} }
@ -1099,11 +1106,13 @@ dshow_vdec_register (GstPlugin * plugin)
(GInstanceInitFunc) gst_dshowvideodec_init, (GInstanceInitFunc) gst_dshowvideodec_init,
}; };
gint i; gint i;
HRESULT hr;
GST_DEBUG_CATEGORY_INIT (dshowvideodec_debug, "dshowvideodec", 0, GST_DEBUG_CATEGORY_INIT (dshowvideodec_debug, "dshowvideodec", 0,
"Directshow filter video decoder"); "Directshow filter video decoder");
CoInitializeEx (NULL, COINIT_MULTITHREADED); hr = CoInitialize (0);
for (i = 0; i < sizeof (video_dec_codecs) / sizeof (CodecEntry); i++) { for (i = 0; i < sizeof (video_dec_codecs) / sizeof (CodecEntry); i++) {
GType type; GType type;
@ -1133,6 +1142,8 @@ dshow_vdec_register (GstPlugin * plugin)
} }
} }
CoUninitialize (); if (SUCCEEDED (hr))
CoUninitialize ();
return TRUE; return TRUE;
} }

View File

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

View File

@ -211,9 +211,13 @@ gst_dshowvideosink_clear (GstDshowVideoSink *sink)
static void static void
gst_dshowvideosink_init (GstDshowVideoSink * sink, GstDshowVideoSinkClass * klass) gst_dshowvideosink_init (GstDshowVideoSink * sink, GstDshowVideoSinkClass * klass)
{ {
HRESULT hr;
gst_dshowvideosink_clear (sink); 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? */ /* TODO: Copied from GstVideoSink; should we use that as base class? */
/* 20ms is more than enough, 80-130ms is noticable */ /* 20ms is more than enough, 80-130ms is noticable */
@ -229,7 +233,10 @@ gst_dshowvideosink_finalize (GObject * gobject)
if (sink->preferredrenderer) if (sink->preferredrenderer)
g_free (sink->preferredrenderer); g_free (sink->preferredrenderer);
CoUninitialize (); if (sink->comInitialized) {
CoUninitialize ();
sink->comInitialized = FALSE;
}
G_OBJECT_CLASS (parent_class)->finalize (gobject); 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 */ /* If we use an app-supplied window, we need to hook its WNDPROC */
WNDPROC prevWndProc; WNDPROC prevWndProc;
gboolean comInitialized;
}; };
struct _GstDshowVideoSinkClass struct _GstDshowVideoSinkClass