Simplify avmedia::SoundHandler

Change-Id: I253d6eda265e3e93d4b85ac35376a96676a68553
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/178050
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
This commit is contained in:
Mike Kaganski 2024-12-07 22:12:08 +05:00
parent 04c62acc63
commit 762d76d9a4
2 changed files with 9 additions and 75 deletions

View file

@ -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<sal_Int8>();
}
css::uno::Sequence< css::uno::Type > SAL_CALL SoundHandler::getTypes()
{
static ::cppu::OTypeCollection aTypeCollection(
cppu::UnoType<css::lang::XTypeProvider>::get(),
cppu::UnoType<css::lang::XServiceInfo>::get(),
cppu::UnoType<css::frame::XNotifyingDispatch>::get(),
cppu::UnoType<css::frame::XDispatch>::get(),
cppu::UnoType<css::document::XExtendedFilterDetection>::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

View file

@ -29,6 +29,7 @@
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <comphelper/compbase.hxx>
#include <cppuhelper/basemutex.hxx>
#include <cppuhelper/weak.hxx>
@ -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<css::lang::XServiceInfo,
css::frame::XNotifyingDispatch, // => 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;