diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2024-03-27 15:48:25 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2024-03-29 18:00:06 +0100 |
commit | 2cc99a2550eac39b9241dec307e66bfdcc005388 (patch) | |
tree | 80314d5a54eca8f4b522ea102b8695d65d3f130d | |
parent | 661ed018fabf3c382867b91828fb8e69d359d9cb (diff) |
convert PlayerListener to comphelper::WeakComponentImplHelper
Change-Id: I167354cbf998dd08ef8b5ffba744758539cabec5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165547
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r-- | avmedia/source/viewer/mediawindow.cxx | 24 | ||||
-rw-r--r-- | include/avmedia/mediawindow.hxx | 11 |
2 files changed, 21 insertions, 14 deletions
diff --git a/avmedia/source/viewer/mediawindow.cxx b/avmedia/source/viewer/mediawindow.cxx index c034eb98ec5e..2a3162db2c2d 100644 --- a/avmedia/source/viewer/mediawindow.cxx +++ b/avmedia/source/viewer/mediawindow.cxx @@ -461,20 +461,19 @@ void MediaWindow::dispatchInsertAVMedia(const css::uno::Reference<css::frame::XD } PlayerListener::PlayerListener(std::function<void(const css::uno::Reference<css::media::XPlayer>&)> fn) - : PlayerListener_BASE(m_aMutex) - , m_aFn(std::move(fn)) + : m_aFn(std::move(fn)) { } -void PlayerListener::dispose() +void PlayerListener::disposing(std::unique_lock<std::mutex>& rGuard) { - stopListening(); - PlayerListener_BASE::dispose(); + stopListening(rGuard); + WeakComponentImplHelperBase::disposing(rGuard); } void PlayerListener::startListening(const css::uno::Reference<media::XPlayerNotifier>& rNotifier) { - osl::MutexGuard aGuard(m_aMutex); + std::unique_lock aGuard(m_aMutex); m_xNotifier = rNotifier; m_xNotifier->addPlayerListener(this); @@ -482,7 +481,12 @@ void PlayerListener::startListening(const css::uno::Reference<media::XPlayerNoti void PlayerListener::stopListening() { - osl::MutexGuard aGuard(m_aMutex); + std::unique_lock aGuard(m_aMutex); + stopListening(aGuard); +} + +void PlayerListener::stopListening(std::unique_lock<std::mutex>&) +{ if (!m_xNotifier) return; m_xNotifier->removePlayerListener(this); @@ -491,12 +495,14 @@ void PlayerListener::stopListening() void SAL_CALL PlayerListener::preferredPlayerWindowSizeAvailable(const css::lang::EventObject&) { - osl::MutexGuard aGuard(m_aMutex); + std::unique_lock aGuard(m_aMutex); css::uno::Reference<media::XPlayer> xPlayer(m_xNotifier, css::uno::UNO_QUERY_THROW); + aGuard.unlock(); callPlayerWindowSizeAvailable(xPlayer); + aGuard.lock(); - stopListening(); + stopListening(aGuard); } void SAL_CALL PlayerListener::disposing(const css::lang::EventObject&) diff --git a/include/avmedia/mediawindow.hxx b/include/avmedia/mediawindow.hxx index 087054c2244b..78e1d0c66152 100644 --- a/include/avmedia/mediawindow.hxx +++ b/include/avmedia/mediawindow.hxx @@ -24,8 +24,7 @@ #include <com/sun/star/awt/Size.hpp> #include <com/sun/star/uno/Reference.hxx> #include <com/sun/star/media/XPlayerListener.hpp> -#include <cppuhelper/compbase.hxx> -#include <cppuhelper/basemutex.hxx> +#include <comphelper/compbase.hxx> #include <vcl/vclptr.hxx> #include <avmedia/avmediadllapi.h> @@ -55,9 +54,9 @@ namespace avmedia namespace priv { class MediaWindowImpl; } - typedef cppu::WeakComponentImplHelper<css::media::XPlayerListener> PlayerListener_BASE; + typedef comphelper::WeakComponentImplHelper<css::media::XPlayerListener> PlayerListener_BASE; - class AVMEDIA_DLLPUBLIC PlayerListener final : public cppu::BaseMutex, public PlayerListener_BASE + class AVMEDIA_DLLPUBLIC PlayerListener final : public PlayerListener_BASE { private: css::uno::Reference<css::media::XPlayerNotifier> m_xNotifier; @@ -66,7 +65,7 @@ namespace avmedia using WeakComponentImplHelperBase::disposing; public: PlayerListener(std::function<void(const css::uno::Reference<css::media::XPlayer>&)> fn); - virtual void SAL_CALL dispose() override; + virtual void disposing(std::unique_lock<std::mutex>& rGuard) override; virtual ~PlayerListener() override; virtual void SAL_CALL preferredPlayerWindowSizeAvailable(const css::lang::EventObject& rSource) override; @@ -76,6 +75,8 @@ namespace avmedia void stopListening(); void callPlayerWindowSizeAvailable(const css::uno::Reference<css::media::XPlayer>& rPlayer) { m_aFn(rPlayer); } + private: + void stopListening(std::unique_lock<std::mutex>& rGuard); }; class AVMEDIA_DLLPUBLIC MediaWindow |