[vlc-commits] upnp: use vlc::threads
Rémi Denis-Courmont
git at videolan.org
Tue Feb 18 19:40:13 CET 2020
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Tue Feb 18 20:36:17 2020 +0200| [6f2fca8b4cab606febb9c22c9011e101e8795794] | committer: Rémi Denis-Courmont
upnp: use vlc::threads
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=6f2fca8b4cab606febb9c22c9011e101e8795794
---
modules/services_discovery/upnp-wrapper.cpp | 13 ++++++-------
modules/services_discovery/upnp-wrapper.hpp | 3 ++-
2 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/modules/services_discovery/upnp-wrapper.cpp b/modules/services_discovery/upnp-wrapper.cpp
index 8190aa0a6d..b8455a5b4a 100644
--- a/modules/services_discovery/upnp-wrapper.cpp
+++ b/modules/services_discovery/upnp-wrapper.cpp
@@ -34,11 +34,10 @@
#endif
#include "upnp-wrapper.hpp"
-#include <vlc_cxx_helpers.hpp>
UpnpInstanceWrapper* UpnpInstanceWrapper::s_instance;
UpnpInstanceWrapper::Listeners UpnpInstanceWrapper::s_listeners;
-vlc_mutex_t UpnpInstanceWrapper::s_lock = VLC_STATIC_MUTEX;
+vlc::threads::mutex UpnpInstanceWrapper::s_lock;
UpnpInstanceWrapper::UpnpInstanceWrapper()
: m_handle( -1 )
@@ -54,7 +53,7 @@ UpnpInstanceWrapper::~UpnpInstanceWrapper()
UpnpInstanceWrapper *UpnpInstanceWrapper::get(vlc_object_t *p_obj)
{
- vlc_mutex_locker lock( &s_lock );
+ vlc::threads::mutex_locker lock( s_lock );
if ( s_instance == NULL )
{
UpnpInstanceWrapper* instance = new(std::nothrow) UpnpInstanceWrapper;
@@ -113,7 +112,7 @@ UpnpInstanceWrapper *UpnpInstanceWrapper::get(vlc_object_t *p_obj)
void UpnpInstanceWrapper::release()
{
UpnpInstanceWrapper *p_delete = NULL;
- vlc::threads::mutex_locker lock( &s_lock );
+ vlc::threads::mutex_locker lock( s_lock );
if (--s_instance->m_refcount == 0)
{
p_delete = s_instance;
@@ -129,7 +128,7 @@ UpnpClient_Handle UpnpInstanceWrapper::handle() const
int UpnpInstanceWrapper::Callback(Upnp_EventType event_type, UpnpEventPtr p_event, void *p_user_data)
{
- vlc::threads::mutex_locker lock( &s_lock );
+ vlc::threads::mutex_locker lock( s_lock );
for (Listeners::iterator iter = s_listeners.begin(); iter != s_listeners.end(); ++iter)
{
(*iter)->onEvent(event_type, p_event, p_user_data);
@@ -140,14 +139,14 @@ int UpnpInstanceWrapper::Callback(Upnp_EventType event_type, UpnpEventPtr p_even
void UpnpInstanceWrapper::addListener(ListenerPtr listener)
{
- vlc::threads::mutex_locker lock( &s_lock );
+ vlc::threads::mutex_locker lock( s_lock );
if ( std::find( s_listeners.begin(), s_listeners.end(), listener) == s_listeners.end() )
s_listeners.push_back( std::move(listener) );
}
void UpnpInstanceWrapper::removeListener(ListenerPtr listener)
{
- vlc::threads::mutex_locker lock( &s_lock );
+ vlc::threads::mutex_locker lock( s_lock );
Listeners::iterator iter = std::find( s_listeners.begin(), s_listeners.end(), listener );
if ( iter != s_listeners.end() )
s_listeners.erase( iter );
diff --git a/modules/services_discovery/upnp-wrapper.hpp b/modules/services_discovery/upnp-wrapper.hpp
index 643ce19245..ba132dc50b 100644
--- a/modules/services_discovery/upnp-wrapper.hpp
+++ b/modules/services_discovery/upnp-wrapper.hpp
@@ -29,6 +29,7 @@
#include <vlc_common.h>
#include <vlc_charset.h>
+#include <vlc_cxx_helpers.hpp>
#include <memory>
#include <vector>
@@ -69,7 +70,7 @@ public:
private:
static UpnpInstanceWrapper* s_instance;
- static vlc_mutex_t s_lock;
+ static vlc::threads::mutex s_lock;
UpnpClient_Handle m_handle;
int m_refcount;
typedef std::shared_ptr<Listener> ListenerPtr;
More information about the vlc-commits
mailing list