[vlc-commits] win32: add assertions for unchecked CoInitializeEx() calls

Rémi Denis-Courmont git at videolan.org
Mon Mar 16 18:30:44 CET 2015


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Mon Mar 16 19:03:02 2015 +0200| [b6f66cf92315698c6d697580429bfead651148e2] | committer: Rémi Denis-Courmont

win32: add assertions for unchecked CoInitializeEx() calls

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=b6f66cf92315698c6d697580429bfead651148e2
---

 modules/access/dshow/dshow.cpp                    |    3 ++-
 modules/access/dtv/bdagraph.cpp                   |    5 ++++-
 modules/codec/dmo/dmo.c                           |    8 ++++++--
 modules/codec/mft.c                               |    5 ++++-
 modules/gui/qt4/components/simple_preferences.cpp |    4 +++-
 modules/gui/qt4/main_interface_win32.cpp          |    5 ++++-
 modules/video_output/msw/common.c                 |    3 ++-
 7 files changed, 25 insertions(+), 8 deletions(-)

diff --git a/modules/access/dshow/dshow.cpp b/modules/access/dshow/dshow.cpp
index 107edd5..cbb4fe6 100644
--- a/modules/access/dshow/dshow.cpp
+++ b/modules/access/dshow/dshow.cpp
@@ -409,7 +409,8 @@ static int CommonOpen( vlc_object_t *p_this, access_sys_t *p_sys,
     bool b_use_video = true;
 
     /* Initialize OLE/COM */
-    CoInitializeEx( NULL, COINIT_APARTMENTTHREADED );
+    if( FAILED(CoInitializeEx( NULL, COINIT_APARTMENTTHREADED )) )
+        vlc_assert_unreachable();
 
     var_Create( p_this,  CFG_PREFIX "config", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
     var_Create( p_this,  CFG_PREFIX "tuner", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
diff --git a/modules/access/dtv/bdagraph.cpp b/modules/access/dtv/bdagraph.cpp
index fd33a60..997c5b4 100644
--- a/modules/access/dtv/bdagraph.cpp
+++ b/modules/access/dtv/bdagraph.cpp
@@ -29,6 +29,8 @@
 # include <config.h>
 #endif
 
+#include <assert.h>
+
 #include <vlc_common.h>
 #include <vlc_block.h>
 #include "dtv/bdagraph.hpp"
@@ -372,7 +374,8 @@ BDAGraph::BDAGraph( vlc_object_t *p_this ):
     p_scanning_tuner = NULL;
     p_grabber = NULL;
 
-    CoInitializeEx( NULL, COINIT_APARTMENTTHREADED );
+    if( FAILED(CoInitializeEx( NULL, COINIT_APARTMENTTHREADED )) )
+        vlc_assert_unreachable();
 }
 
 /*****************************************************************************
diff --git a/modules/codec/dmo/dmo.c b/modules/codec/dmo/dmo.c
index 2b92d78..3bd5b14 100644
--- a/modules/codec/dmo/dmo.c
+++ b/modules/codec/dmo/dmo.c
@@ -29,6 +29,8 @@
 # include "config.h"
 #endif
 
+#include <assert.h>
+
 #include <vlc_common.h>
 #include <vlc_plugin.h>
 #include <vlc_codec.h>
@@ -366,7 +368,8 @@ static int DecOpen( decoder_t *p_dec )
     WAVEFORMATEX *p_wf = NULL;
 
     /* Initialize OLE/COM */
-    CoInitializeEx( NULL, COINIT_APARTMENTTHREADED );
+    if( FAILED(CoInitializeEx( NULL, COINIT_APARTMENTTHREADED )) )
+        vlc_assert_unreachable();
 
     if( LoadDMO( VLC_OBJECT(p_dec), &hmsdmo_dll, &p_dmo, &p_dec->fmt_in, false )
         != VLC_SUCCESS )
@@ -1394,7 +1397,8 @@ static int EncOpen( vlc_object_t *p_this )
     HINSTANCE hmsdmo_dll = NULL;
 
     /* Initialize OLE/COM */
-    CoInitializeEx( NULL, COINIT_APARTMENTTHREADED );
+    if( FAILED(CoInitializeEx( NULL, COINIT_APARTMENTTHREADED )) )
+        vlc_assert_unreachable();
 
     if( LoadDMO( p_this, &hmsdmo_dll, &p_dmo, &p_enc->fmt_out, true )
         != VLC_SUCCESS )
diff --git a/modules/codec/mft.c b/modules/codec/mft.c
index 7dffde3..bc32b46 100644
--- a/modules/codec/mft.c
+++ b/modules/codec/mft.c
@@ -37,6 +37,8 @@
 # define STDCALL __stdcall
 #endif
 
+#include <assert.h>
+
 #include <vlc_common.h>
 #include <vlc_plugin.h>
 #include <vlc_codec.h>
@@ -1121,7 +1123,8 @@ int Open(vlc_object_t *p_this)
     if (!p_sys)
         return VLC_ENOMEM;
 
-    CoInitializeEx(NULL, COINIT_MULTITHREADED);
+    if( FAILED(CoInitializeEx(NULL, COINIT_MULTITHREADED)) )
+        vlc_assert_unreachable();
 
     if (LoadMFTLibrary(&p_sys->mf_handle))
     {
diff --git a/modules/gui/qt4/components/simple_preferences.cpp b/modules/gui/qt4/components/simple_preferences.cpp
index 5b65da5..5e6ab6c 100644
--- a/modules/gui/qt4/components/simple_preferences.cpp
+++ b/modules/gui/qt4/components/simple_preferences.cpp
@@ -44,6 +44,7 @@
 #include <QSettings>
 #include <QtAlgorithms>
 #include <QDir>
+#include <assert.h>
 #include <math.h>
 
 #define ICON_HEIGHT 48
@@ -1255,7 +1256,8 @@ void SPrefsPanel::assoDialog()
 #endif /* __IApplicationAssociationRegistrationUI_INTERFACE_DEFINED__ */
 
     IApplicationAssociationRegistrationUI *p_appassoc;
-    CoInitializeEx( NULL, COINIT_MULTITHREADED );
+    if( FAILED(CoInitializeEx( NULL, COINIT_MULTITHREADED )) )
+        vlc_assert_unreachable();
 
     if( S_OK == CoCreateInstance(CLSID_ApplicationAssociationRegistrationUI,
                 NULL, CLSCTX_INPROC_SERVER,
diff --git a/modules/gui/qt4/main_interface_win32.cpp b/modules/gui/qt4/main_interface_win32.cpp
index c16293a..cd045cc 100644
--- a/modules/gui/qt4/main_interface_win32.cpp
+++ b/modules/gui/qt4/main_interface_win32.cpp
@@ -32,6 +32,8 @@
 #include <QBitmap>
 #include <vlc_windows_interfaces.h>
 
+#include <assert.h>
+
 #if defined(_WIN32) && HAS_QT5
 # include <QWindow>
 # include <qpa/qplatformnativeinterface.h>
@@ -115,7 +117,8 @@ void MainInterface::createTaskBarButtons()
     FIXME:the play button's picture doesn't changed to pause when clicked
     */
 
-    CoInitializeEx( NULL, COINIT_MULTITHREADED );
+    if( FAILED(CoInitializeEx( NULL, COINIT_MULTITHREADED )) )
+        vlc_assert_unreachable();
 
     if( S_OK == CoCreateInstance( CLSID_TaskbarList,
                 NULL, CLSCTX_INPROC_SERVER,
diff --git a/modules/video_output/msw/common.c b/modules/video_output/msw/common.c
index 8de44fd..77679cd 100644
--- a/modules/video_output/msw/common.c
+++ b/modules/video_output/msw/common.c
@@ -283,7 +283,8 @@ static void CommonChangeThumbnailClip(vout_display_t *vd, bool show)
     if (!GetVersionEx(&winVer) || winVer.dwMajorVersion <= 5)
         return;
 
-    CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
+    if( FAILED(CoInitializeEx(NULL, COINIT_APARTMENTTHREADED)) )
+        vlc_assert_unreachable();
 
     void *ptr;
     if (S_OK == CoCreateInstance(&CLSID_TaskbarList,



More information about the vlc-commits mailing list