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 /avmedia | |
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>
Diffstat (limited to 'avmedia')
-rw-r--r-- | avmedia/source/viewer/mediawindow.cxx | 24 |
1 files changed, 15 insertions, 9 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&) |