diff --git a/modules/javafx.media/src/main/native/gstreamer/gstreamer-lite/gst-plugins-good/sys/directsound/gstdirectsoundnotify.cpp b/modules/javafx.media/src/main/native/gstreamer/gstreamer-lite/gst-plugins-good/sys/directsound/gstdirectsoundnotify.cpp index c9dcb1feca..2d19ff899f 100644 --- a/modules/javafx.media/src/main/native/gstreamer/gstreamer-lite/gst-plugins-good/sys/directsound/gstdirectsoundnotify.cpp +++ b/modules/javafx.media/src/main/native/gstreamer/gstreamer-lite/gst-plugins-good/sys/directsound/gstdirectsoundnotify.cpp @@ -51,6 +51,12 @@ void ReleaseNotificator(void *pObject) { bool GSTDirectSoundNotify::Init(GSTDSNotfierCallback pCallback, void *pData) { m_pCallback = pCallback; m_pData = pData; + bool bCallCoUninitialize = true; + bool bResult = false; + + if (FAILED(CoInitialize(NULL))) { + bCallCoUninitialize = false; + } HRESULT hr = CoCreateInstance(__uuidof(MMDeviceEnumerator), NULL, @@ -59,11 +65,15 @@ bool GSTDirectSoundNotify::Init(GSTDSNotfierCallback pCallback, void *pData) { if (SUCCEEDED(hr)) { hr = m_pEnumerator->RegisterEndpointNotificationCallback(this); if (SUCCEEDED(hr)) { - return true; + bResult = true; } } - return false; + if (bCallCoUninitialize) { + CoUninitialize(); + } + + return bResult; } void GSTDirectSoundNotify::Dispose() { @@ -78,13 +88,6 @@ GSTDirectSoundNotify::GSTDirectSoundNotify() { m_pEnumerator = NULL; m_pCallback = NULL; m_pData = NULL; - m_hrCoInit = CoInitialize(NULL); -} - -GSTDirectSoundNotify::~GSTDirectSoundNotify() { - if (SUCCEEDED(m_hrCoInit)) { - CoUninitialize(); - } } HRESULT GSTDirectSoundNotify::OnDefaultDeviceChanged(EDataFlow flow, @@ -112,7 +115,7 @@ HRESULT GSTDirectSoundNotify::QueryInterface(REFIID iid, void** ppUnk) { AddRef(); - return S_OK; + return S_OK; } ULONG GSTDirectSoundNotify::AddRef() { diff --git a/modules/javafx.media/src/main/native/gstreamer/gstreamer-lite/gst-plugins-good/sys/directsound/gstdirectsoundnotify.h b/modules/javafx.media/src/main/native/gstreamer/gstreamer-lite/gst-plugins-good/sys/directsound/gstdirectsoundnotify.h index 09902027cb..b755c650ca 100644 --- a/modules/javafx.media/src/main/native/gstreamer/gstreamer-lite/gst-plugins-good/sys/directsound/gstdirectsoundnotify.h +++ b/modules/javafx.media/src/main/native/gstreamer/gstreamer-lite/gst-plugins-good/sys/directsound/gstdirectsoundnotify.h @@ -46,7 +46,6 @@ class GSTDirectSoundNotify : IMMNotificationClient { public: GSTDirectSoundNotify(); - ~GSTDirectSoundNotify(); bool Init(GSTDSNotfierCallback pCallback, void *pData); void Dispose(); @@ -67,7 +66,6 @@ class GSTDirectSoundNotify : IMMNotificationClient IMMDeviceEnumerator* m_pEnumerator; GSTDSNotfierCallback m_pCallback; void *m_pData; - HRESULT m_hrCoInit; // IUnknown IFACEMETHODIMP QueryInterface(const IID& iid, void** ppUnk);