avmedia/source/gstreamer/gstplayer.cxx |   13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

New commits:
commit 621143588b3cb438baf27fb6893ab02e7b06f9dd
Author:     Michael Stahl <michael.st...@allotropia.de>
AuthorDate: Tue Mar 21 19:10:14 2023 +0100
Commit:     Michael Stahl <michael.st...@allotropia.de>
CommitDate: Wed Mar 22 08:25:26 2023 +0000

    Revert "avmedia : use std::mutex instead of osl::Mutex"
    
    This reverts commit 477fa6c3cb92f578032dee60482718efdb8f44f2.
    
    MissingPluginInstaller requires a recursive lock:
    
    Thread 2 (Thread 0x7f8e73d69700 (LWP 29931)):
    0  __lll_lock_wait () at /lib64/libpthread.so.0
    ...
    5  std::unique_lock<std::mutex>::lock() (this=0x7f8e73d65a88) at 
/opt/rh/devtoolset-7/root/usr/lib/gcc/x86_64-redhat-linux/7/../../../../include/c++/7/bits/std_mutex.h:267
    6  std::unique_lock<std::mutex>::unique_lock(std::mutex&) 
(this=0x7f8e73d65a88, __m=...) at 
/opt/rh/devtoolset-7/root/usr/lib/gcc/x86_64-redhat-linux/7/../../../../include/c++/7/bits/std_mutex.h:197
    7  avmedia::gstreamer::(anonymous 
namespace)::MissingPluginInstaller::detach(avmedia::gstreamer::Player const*) 
(this=0x7f8e644c6be0 <rtl::Static<avmedia::gstreamer::(anonymous 
namespace)::MissingPluginInstaller, avmedia::gstreamer::(anonymous 
namespace)::TheMissingPluginInstaller>::get()::instance>, source=0x75d2fa0) at 
avmedia/source/gstreamer/gstplayer.cxx:187
    8  avmedia::gstreamer::Player::disposing() (this=0x75d2fa0) at 
avmedia/source/gstreamer/gstplayer.cxx:334
    9  cppu::WeakComponentImplHelperBase::dispose() (this=0x75d2fa0) at 
cppuhelper/source/implbase.cxx:104
    10 cppu::PartialWeakComponentImplHelper<com::sun::star::media::XPlayer, 
com::sun::star::lang::XServiceInfo>::dispose() (this=0x75d2fa0) at 
include/cppuhelper/compbase.hxx:90
    11 cppu::WeakComponentImplHelperBase::release() (this=0x75d2fa0) at 
cppuhelper/source/implbase.cxx:79
    13 rtl::Reference<avmedia::gstreamer::Player>::~Reference() 
(this=0x7f8e7c028f20) at include/rtl/ref.hxx:129
    ...
    21 std::__debug::set<rtl::Reference<avmedia::gstreamer::Player>, 
std::less<rtl::Reference<avmedia::gstreamer::Player> >, 
std::allocator<rtl::Reference<avmedia::gstreamer::Player> > >::clear() 
(this=0x7f8e644c6cd8 <rtl::Static<avmedia::gstreamer::(anonymous 
namespace)::MissingPluginInstaller, avmedia::gstreamer::(anonymous 
namespace)::TheMissingPluginInstaller>::get()::instance+248>) at 
/opt/rh/devtoolset-7/root/usr/lib/gcc/x86_64-redhat-linux/7/../../../../include/c++/7/debug/set.h:426
    22 avmedia::gstreamer::(anonymous 
namespace)::MissingPluginInstaller::report(rtl::Reference<avmedia::gstreamer::Player>
 const&, _GstMessage*) (this=0x7f8e644c6be0 
<rtl::Static<avmedia::gstreamer::(anonymous namespace)::MissingPluginInstaller, 
avmedia::gstreamer::(anonymous 
namespace)::TheMissingPluginInstaller>::get()::instance>, source=..., 
message=0x7cdb400) at avmedia/source/gstreamer/gstplayer.cxx:156
    23 avmedia::gstreamer::Player::processSyncMessage(_GstMessage*) 
(this=0x75abfe0, message=0x7cdb400) at 
avmedia/source/gstreamer/gstplayer.cxx:536
    24 avmedia::gstreamer::pipeline_bus_sync_handler(_GstBus*, _GstMessage*, 
void*) (message=0x7cdb400, data=0x75abfe0) at 
avmedia/source/gstreamer/gstplayer.cxx:382
    25 gst_bus_post () at /lib64/libgstreamer-1.0.so.0
    
    Change-Id: Ia8e7fef4d4cee2dde7189702af6dddf883b6cceb
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149233
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>

diff --git a/avmedia/source/gstreamer/gstplayer.cxx 
b/avmedia/source/gstreamer/gstplayer.cxx
index 7d7602b5b3eb..b841c576be17 100644
--- a/avmedia/source/gstreamer/gstplayer.cxx
+++ b/avmedia/source/gstreamer/gstplayer.cxx
@@ -25,7 +25,6 @@
 #include <cstddef>
 #include <cstring>
 #include <map>
-#include <mutex>
 #include <set>
 #include <vector>
 #include <math.h>
@@ -99,7 +98,7 @@ private:
 
     DECL_STATIC_LINK(MissingPluginInstaller, launchUi, void*, void);
 
-    std::mutex mutex_;
+    osl::Mutex mutex_;
     std::set<OString> reported_;
     std::map<OString, std::set<rtl::Reference<Player>>> queued_;
     rtl::Reference<MissingPluginInstallerThread> currentThread_;
@@ -111,7 +110,7 @@ private:
 
 
 MissingPluginInstaller::~MissingPluginInstaller() {
-    std::unique_lock g(mutex_);
+    osl::MutexGuard g(mutex_);
     SAL_WARN_IF(currentThread_.is(), "avmedia.gstreamer", "unjoined thread");
     inCleanUp_ = true;
 }
@@ -139,7 +138,7 @@ void MissingPluginInstaller::report(
     rtl::Reference<MissingPluginInstallerThread> join;
     rtl::Reference<MissingPluginInstallerThread> launch;
     {
-        std::unique_lock g(mutex_);
+        osl::MutexGuard g(mutex_);
         if (reported_.find(detStr) != reported_.end()) {
             return;
         }
@@ -184,7 +183,7 @@ void eraseSource(std::set<rtl::Reference<Player>> & set, 
Player const * source)
 void MissingPluginInstaller::detach(Player const * source) {
     rtl::Reference<MissingPluginInstallerThread> join;
     {
-        std::unique_lock g(mutex_);
+        osl::MutexGuard g(mutex_);
         if (inCleanUp_) {
             // Guard against ~MissingPluginInstaller with erroneously un-joined
             // currentThread_ (thus non-empty currentSources_) calling
@@ -256,7 +255,7 @@ void MissingPluginInstallerThread::execute() {
     for (;;) {
         std::vector<OString> details;
         {
-            std::unique_lock g(inst.mutex_);
+            osl::MutexGuard g(inst.mutex_);
             assert(!inst.currentDetails_.empty());
             details.swap(inst.currentDetails_);
         }
@@ -269,7 +268,7 @@ void MissingPluginInstallerThread::execute() {
         args.push_back(nullptr);
         gst_install_plugins_sync(args.data(), nullptr);
         {
-            std::unique_lock g(inst.mutex_);
+            osl::MutexGuard g(inst.mutex_);
             if (inst.queued_.empty() || inst.launchNewThread_) {
                 inst.launchNewThread_ = true;
                 break;

Reply via email to