diff options
Diffstat (limited to 'avmedia/source/win/player.cxx')
-rw-r--r-- | avmedia/source/win/player.cxx | 65 |
1 files changed, 11 insertions, 54 deletions
diff --git a/avmedia/source/win/player.cxx b/avmedia/source/win/player.cxx index 4d764d4a4fa6..b52ac8171dfc 100644 --- a/avmedia/source/win/player.cxx +++ b/avmedia/source/win/player.cxx @@ -32,7 +32,7 @@ #include <rtl/ref.hxx> constexpr OUStringLiteral AVMEDIA_WIN_PLAYER_IMPLEMENTATIONNAME = u"com.sun.star.comp.avmedia.Player_DirectX"; -constexpr OUStringLiteral AVMEDIA_WIN_PLAYER_SERVICENAME = u"com.sun.star.media.Player_DirectX"; +constexpr OUString AVMEDIA_WIN_PLAYER_SERVICENAME = u"com.sun.star.media.Player_DirectX"_ustr; using namespace ::com::sun::star; @@ -64,23 +64,14 @@ static LRESULT CALLBACK MediaPlayerWndProc_2( HWND hWnd,UINT nMsg, WPARAM nPar1, Player::Player() : Player_BASE(m_aMutex), - mpGB( nullptr ), - mpOMF( nullptr ), - mpMC( nullptr ), - mpME( nullptr ), - mpMS( nullptr ), - mpMP( nullptr ), - mpBA( nullptr ), - mpBV( nullptr ), - mpVW( nullptr ), - mpEV( nullptr ), + 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 ); } @@ -88,8 +79,6 @@ Player::~Player() { if( mnFrameWnd ) ::DestroyWindow( mnFrameWnd ); - - ::CoUninitialize(); } @@ -97,47 +86,16 @@ void SAL_CALL Player::disposing() { ::osl::MutexGuard aGuard(m_aMutex); stop(); - if( mpBA ) - mpBA->Release(); - - if( mpBV ) - mpBV->Release(); - - if( mpVW ) - mpVW->Release(); - - if( mpMP ) - mpMP->Release(); - - if( mpMS ) - mpMS->Release(); - if( mpME ) - { mpME->SetNotifyWindow( 0, WM_GRAPHNOTIFY, 0); - mpME->Release(); - } - - if( mpMC ) - mpMC->Release(); - - if( mpEV ) - mpEV->Release(); - - if( mpOMF ) - mpOMF->Release(); - - if( mpGB ) - mpGB->Release(); } bool Player::create( const OUString& rURL ) { - HRESULT hR; bool bRet = false; - if( SUCCEEDED( hR = CoCreateInstance( CLSID_FilterGraph, nullptr, CLSCTX_INPROC_SERVER, IID_IGraphBuilder, reinterpret_cast<void**>(&mpGB) ) ) ) + if( SUCCEEDED(mpGB.CoCreateInstance(CLSID_FilterGraph, nullptr, CLSCTX_INPROC_SERVER)) ) { // Don't use the overlay mixer on Windows Vista // It disables the desktop composition as soon as RenderFile is called @@ -149,18 +107,17 @@ bool Player::create( const OUString& rURL ) if (aFile.startsWithIgnoreAsciiCase("file:")) osl::FileBase::getSystemPathFromFileURL(rURL, aFile); - if( SUCCEEDED( hR = mpGB->RenderFile( o3tl::toW(aFile.getStr()), nullptr ) ) && - SUCCEEDED( hR = mpGB->QueryInterface( IID_IMediaControl, reinterpret_cast<void**>(&mpMC) ) ) && - SUCCEEDED( hR = mpGB->QueryInterface( IID_IMediaEventEx, reinterpret_cast<void**>(&mpME) ) ) && - SUCCEEDED( hR = mpGB->QueryInterface( IID_IMediaSeeking, reinterpret_cast<void**>(&mpMS) ) ) && - SUCCEEDED( hR = mpGB->QueryInterface( IID_IMediaPosition, reinterpret_cast<void**>(&mpMP) ) ) ) + if( SUCCEEDED( mpGB->RenderFile( o3tl::toW(aFile.getStr()), nullptr ) ) && + mpMC.set(mpGB, sal::systools::COM_QUERY) && + mpME.set(mpGB, sal::systools::COM_QUERY) && + mpMP.set(mpGB, sal::systools::COM_QUERY) ) { // Video interfaces - mpGB->QueryInterface( IID_IVideoWindow, reinterpret_cast<void**>(&mpVW) ); - mpGB->QueryInterface( IID_IBasicVideo, reinterpret_cast<void**>(&mpBV) ); + mpVW.set(mpGB, sal::systools::COM_QUERY); + mpBV.set(mpGB, sal::systools::COM_QUERY); // Audio interface - mpGB->QueryInterface( IID_IBasicAudio, reinterpret_cast<void**>(&mpBA) ); + mpBA.set(mpGB, sal::systools::COM_QUERY); if( mpBA ) mpBA->put_Volume( mnUnmutedVolume ); |