diff --git a/ChangeLog b/ChangeLog index 98454757d0..b30cfa31e0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2008-08-13 Michael Smith + + * 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 * gst/rtpmanager/gstrtpbin.c: (gst_rtp_bin_associate), diff --git a/sys/dshowdecwrapper/gstdshowaudiodec.c b/sys/dshowdecwrapper/gstdshowaudiodec.c index d5b5d7fd0a..e436beb8c2 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 d667aa4693..732e636d43 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 812b32c440..3c95771d14 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 0989dabc43..0ab7a5d71e 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 b191c98b03..788dbdd5cc 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 69ac28e2cd..fd03c2b7e3 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