[vlc-commits] upnp-wrapper: Minor simplifications

Hugo Beauzée-Luyssen git at videolan.org
Wed Nov 21 15:33:36 CET 2018


vlc | branch: master | Hugo Beauzée-Luyssen <hugo at beauzee.fr> | Tue Nov 20 12:02:13 2018 +0100| [bf1d25097c8e1ba5298dedabf6ff556f901cef8f] | committer: Hugo Beauzée-Luyssen

upnp-wrapper: Minor simplifications

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=bf1d25097c8e1ba5298dedabf6ff556f901cef8f
---

 modules/services_discovery/upnp-wrapper.cpp | 23 ++++++-----------------
 1 file changed, 6 insertions(+), 17 deletions(-)

diff --git a/modules/services_discovery/upnp-wrapper.cpp b/modules/services_discovery/upnp-wrapper.cpp
index 95b1847c79..c001492f37 100644
--- a/modules/services_discovery/upnp-wrapper.cpp
+++ b/modules/services_discovery/upnp-wrapper.cpp
@@ -141,26 +141,15 @@ int UpnpInstanceWrapper::Callback(Upnp_EventType event_type, UpnpEventPtr p_even
 
 void UpnpInstanceWrapper::addListener(ListenerPtr listener)
 {
-    vlc_mutex_lock( &s_lock );
-    if ( std::find( s_listeners.begin(), s_listeners.end(), listener) != s_listeners.end() )
-    {
-        vlc_mutex_unlock( &s_lock );
-        return;
-    }
-    s_listeners.push_back( std::move(listener) );
-    vlc_mutex_unlock( &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_mutex_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() )
-    {
-        vlc_mutex_unlock( &s_lock );
-        return;
-    }
-
-    s_listeners.erase( iter );
-    vlc_mutex_unlock( &s_lock );
+    if ( iter != s_listeners.end() )
+        s_listeners.erase( iter );
 }



More information about the vlc-commits mailing list