From 762d76d9a44704af45b4989f900a906f8f7aa3a3 Mon Sep 17 00:00:00 2001 From: Mike Kaganski Date: Sat, 7 Dec 2024 22:12:08 +0500 Subject: [PATCH] Simplify avmedia::SoundHandler Change-Id: I253d6eda265e3e93d4b85ac35376a96676a68553 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/178050 Tested-by: Jenkins Reviewed-by: Mike Kaganski --- avmedia/source/framework/soundhandler.cxx | 62 ++--------------------- avmedia/source/framework/soundhandler.hxx | 22 ++------ 2 files changed, 9 insertions(+), 75 deletions(-) diff --git a/avmedia/source/framework/soundhandler.cxx b/avmedia/source/framework/soundhandler.cxx index d3cc8b724d39..5af9aca90594 100644 --- a/avmedia/source/framework/soundhandler.cxx +++ b/avmedia/source/framework/soundhandler.cxx @@ -33,61 +33,7 @@ namespace avmedia{ -// XInterface, XTypeProvider, XServiceInfo - - -void SAL_CALL SoundHandler::acquire() noexcept -{ - /* Don't use mutex in methods of XInterface! */ - OWeakObject::acquire(); -} - -void SAL_CALL SoundHandler::release() noexcept -{ - /* Don't use mutex in methods of XInterface! */ - OWeakObject::release(); -} - -css::uno::Any SAL_CALL SoundHandler::queryInterface( const css::uno::Type& aType ) -{ - /* Attention: Don't use mutex or guard in this method!!! Is a method of XInterface. */ - /* Ask for my own supported interfaces ...*/ - css::uno::Any aReturn( ::cppu::queryInterface( aType, - static_cast< css::lang::XTypeProvider* >(this), - static_cast< css::lang::XServiceInfo* >(this), - static_cast< css::frame::XNotifyingDispatch* >(this), - static_cast< css::frame::XDispatch* >(this), - static_cast< css::document::XExtendedFilterDetection* >(this))); - /* If searched interface not supported by this class ... */ - if ( !aReturn.hasValue() ) - { - /* ... ask baseclass for interfaces! */ - aReturn = OWeakObject::queryInterface( aType ); - } - /* Return result of this search. */ - return aReturn; -} - -css::uno::Sequence< sal_Int8 > SAL_CALL SoundHandler::getImplementationId() -{ - return css::uno::Sequence(); -} - -css::uno::Sequence< css::uno::Type > SAL_CALL SoundHandler::getTypes() -{ - static ::cppu::OTypeCollection aTypeCollection( - cppu::UnoType::get(), - cppu::UnoType::get(), - cppu::UnoType::get(), - cppu::UnoType::get(), - cppu::UnoType::get()); - - return aTypeCollection.getTypes(); -} - -/*===========================================================================================================*/ -/* XServiceInfo */ -/*===========================================================================================================*/ +// XServiceInfo OUString SAL_CALL SoundHandler::getImplementationName() { return u"com.sun.star.comp.framework.SoundHandler"_ustr; @@ -162,7 +108,7 @@ void SAL_CALL SoundHandler::dispatchWithNotification(const css::util::URL& const css::uno::Reference< css::frame::XDispatchResultListener >& xListener ) { // SAFE { - const ::osl::MutexGuard aLock( m_aMutex ); + const std::unique_lock aLock(m_aMutex); utl::MediaDescriptor aDescriptor(lDescriptor); @@ -274,7 +220,7 @@ OUString SAL_CALL SoundHandler::detect( css::uno::Sequence< css::beans::Property IMPL_LINK_NOARG(SoundHandler, implts_PlayerNotify, Timer *, void) { // SAFE { - ::osl::ClearableMutexGuard aLock( m_aMutex ); + std::unique_lock aLock(m_aMutex); if (m_xPlayer.is() && m_xPlayer->isPlaying() && m_xPlayer->getMediaTime() < m_xPlayer->getDuration()) { @@ -304,7 +250,7 @@ IMPL_LINK_NOARG(SoundHandler, implts_PlayerNotify, Timer *, void) // } SAFE //release aLock before end of method at which point xOperationHold goes out of scope and pThis dies - aLock.clear(); + aLock.unlock(); } } // namespace framework diff --git a/avmedia/source/framework/soundhandler.hxx b/avmedia/source/framework/soundhandler.hxx index 648cbe59dd4b..a143fcb87eaa 100644 --- a/avmedia/source/framework/soundhandler.hxx +++ b/avmedia/source/framework/soundhandler.hxx @@ -29,6 +29,7 @@ #include +#include #include #include @@ -49,15 +50,9 @@ namespace avmedia{ @devstatus ready @threadsafe yes *//*-*************************************************************************************************************/ -class SoundHandler : // interfaces - public css::lang::XTypeProvider - , public css::lang::XServiceInfo - , public css::frame::XNotifyingDispatch // => XDispatch - , public css::document::XExtendedFilterDetection - // baseclasses - // Order is necessary for right initialization! - , private cppu::BaseMutex - , public ::cppu::OWeakObject +class SoundHandler : public comphelper::WeakImplHelper XDispatch + css::document::XExtendedFilterDetection> { // public methods public: @@ -66,14 +61,7 @@ class SoundHandler : // interfaces SoundHandler(); virtual ~SoundHandler( ) override; - // XInterface, XTypeProvider, XServiceInfo - virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type& aType ) override; - virtual void SAL_CALL acquire() noexcept override; - virtual void SAL_CALL release() noexcept override; - virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes () override; - virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override; - - /* interface XServiceInfo */ + // XServiceInfo virtual OUString SAL_CALL getImplementationName ( ) override; virtual sal_Bool SAL_CALL supportsService ( const OUString& sServiceName ) override; virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames ( ) override;