diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2021-12-21 16:19:46 +0300 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2021-12-21 17:03:30 +0100 |
commit | c35f81148fb18ba070516edcbb4d614444899235 (patch) | |
tree | a7411001321a0745f161787fcc2be978e2c94e0a /avmedia | |
parent | 9466e895b319fc695cc326b37ee773e14b465c0a (diff) |
Use sal::systools::CoInitializeGuard and sal::systools::ThrowIfFailed
Change-Id: Ifb40e7672671df03b5ffc89905ad1e7b68451b68
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127232
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'avmedia')
-rw-r--r-- | avmedia/source/win/framegrabber.cxx | 9 | ||||
-rw-r--r-- | avmedia/source/win/framegrabber.hxx | 5 | ||||
-rw-r--r-- | avmedia/source/win/player.cxx | 5 | ||||
-rw-r--r-- | avmedia/source/win/player.hxx | 3 |
4 files changed, 11 insertions, 11 deletions
diff --git a/avmedia/source/win/framegrabber.cxx b/avmedia/source/win/framegrabber.cxx index 17fb229ef057..42e30219caf3 100644 --- a/avmedia/source/win/framegrabber.cxx +++ b/avmedia/source/win/framegrabber.cxx @@ -38,7 +38,6 @@ #include <vcl/graph.hxx> #include <vcl/dibtools.hxx> #include <o3tl/char16_t2wchar_t.hxx> -#include <systools/win32/comtools.hxx> constexpr OUStringLiteral AVMEDIA_WIN_FRAMEGRABBER_IMPLEMENTATIONNAME = u"com.sun.star.comp.avmedia.FrameGrabber_DirectX"; constexpr OUStringLiteral AVMEDIA_WIN_FRAMEGRABBER_SERVICENAME = u"com.sun.star.media.FrameGrabber_DirectX"; @@ -49,15 +48,13 @@ namespace avmedia::win { FrameGrabber::FrameGrabber() + : sal::systools::CoInitializeGuard(COINIT_APARTMENTTHREADED, false, + sal::systools::CoInitializeGuard::WhenFailed::NoThrow) { - ::CoInitializeEx( nullptr, COINIT_APARTMENTTHREADED ); } -FrameGrabber::~FrameGrabber() -{ - ::CoUninitialize(); -} +FrameGrabber::~FrameGrabber() = default; namespace { diff --git a/avmedia/source/win/framegrabber.hxx b/avmedia/source/win/framegrabber.hxx index fb4fda35905d..d1ca48e84230 100644 --- a/avmedia/source/win/framegrabber.hxx +++ b/avmedia/source/win/framegrabber.hxx @@ -21,6 +21,8 @@ #include "wincommon.hxx" #include <cppuhelper/implbase.hxx> +#include <systools/win32/comtools.hxx> + #include <com/sun/star/media/XFrameGrabber.hpp> struct IMediaDet; @@ -28,7 +30,8 @@ struct IMediaDet; namespace avmedia::win { class FrameGrabber : public ::cppu::WeakImplHelper< css::media::XFrameGrabber, - css::lang::XServiceInfo > + css::lang::XServiceInfo >, + public sal::systools::CoInitializeGuard { public: explicit FrameGrabber(); diff --git a/avmedia/source/win/player.cxx b/avmedia/source/win/player.cxx index 23fdb241b3f5..7f6660ab8462 100644 --- a/avmedia/source/win/player.cxx +++ b/avmedia/source/win/player.cxx @@ -64,13 +64,14 @@ static LRESULT CALLBACK MediaPlayerWndProc_2( HWND hWnd,UINT nMsg, WPARAM nPar1, Player::Player() : Player_BASE(m_aMutex), + sal::systools::CoInitializeGuard(COINIT_APARTMENTTHREADED, false, + sal::systools::CoInitializeGuard::WhenFailed::NoThrow), mnUnmutedVolume( 0 ), mnFrameWnd( nullptr ), mbMuted( false ), mbLooping( false ), mbAddWindow( true ) { - ::CoInitializeEx( nullptr, COINIT_APARTMENTTHREADED ); } @@ -78,8 +79,6 @@ Player::~Player() { if( mnFrameWnd ) ::DestroyWindow( mnFrameWnd ); - - ::CoUninitialize(); } diff --git a/avmedia/source/win/player.hxx b/avmedia/source/win/player.hxx index 20806251c8bc..1563d549a85e 100644 --- a/avmedia/source/win/player.hxx +++ b/avmedia/source/win/player.hxx @@ -51,7 +51,8 @@ typedef ::cppu::WeakComponentImplHelper< css::media::XPlayer, class Player : public cppu::BaseMutex, - public Player_BASE + public Player_BASE, + public sal::systools::CoInitializeGuard { public: |