[vlc-commits] upnp: remove MediaServerList::m_lock, it' s always used under s_lock protection
Steve Lhomme
git at videolan.org
Sun Jun 5 14:35:13 CEST 2016
vlc | branch: master | Steve Lhomme <robux4 at videolabs.io> | Thu Jun 2 14:08:18 2016 +0200| [8c653ca42215394267be6630bcd96570d2259088] | committer: Thomas Guillem
upnp: remove MediaServerList::m_lock, it's always used under s_lock protection
Signed-off-by: Thomas Guillem <thomas at gllm.fr>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=8c653ca42215394267be6630bcd96570d2259088
---
modules/services_discovery/upnp.cpp | 21 ++++++++-------------
modules/services_discovery/upnp.hpp | 5 ++---
2 files changed, 10 insertions(+), 16 deletions(-)
diff --git a/modules/services_discovery/upnp.cpp b/modules/services_discovery/upnp.cpp
index 7facaad..09d94fc 100644
--- a/modules/services_discovery/upnp.cpp
+++ b/modules/services_discovery/upnp.cpp
@@ -291,19 +291,17 @@ MediaServerDesc::~MediaServerDesc()
MediaServerList::MediaServerList( services_discovery_t* p_sd )
: m_sd( p_sd )
{
- vlc_mutex_init( &m_lock );
}
MediaServerList::~MediaServerList()
{
vlc_delete_all(m_list);
- vlc_mutex_destroy( &m_lock );
}
-bool MediaServerList::addServerLocked( MediaServerDesc* desc )
+bool MediaServerList::addServer( MediaServerDesc* desc )
{
input_item_t* p_input_item = NULL;
- if ( getServerLocked( desc->UDN ) )
+ if ( getServer( desc->UDN ) )
return false;
msg_Dbg( m_sd, "Adding server '%s' with uuid '%s'", desc->friendlyName.c_str(), desc->UDN.c_str() );
@@ -338,7 +336,7 @@ bool MediaServerList::addServerLocked( MediaServerDesc* desc )
return true;
}
-MediaServerDesc* MediaServerList::getServerLocked( const std::string& udn )
+MediaServerDesc* MediaServerList::getServer( const std::string& udn )
{
std::vector<MediaServerDesc*>::const_iterator it = m_list.begin();
std::vector<MediaServerDesc*>::const_iterator ite = m_list.end();
@@ -388,7 +386,6 @@ void MediaServerList::parseNewServer( IXML_Document *doc, const std::string &loc
if ( !p_device_list )
return;
- vlc_mutex_locker lock( &m_lock );
for ( unsigned int i = 0; i < ixmlNodeList_length( p_device_list ); i++ )
{
IXML_Element* p_device_element = ( IXML_Element* ) ixmlNodeList_item( p_device_list, i );
@@ -419,7 +416,7 @@ void MediaServerList::parseNewServer( IXML_Document *doc, const std::string &loc
}
/* Check if server is already added */
- if ( getServerLocked( psz_udn ) )
+ if ( getServer( psz_udn ) )
{
msg_Warn( m_sd, "Server with uuid '%s' already exists.", psz_udn );
continue;
@@ -463,7 +460,7 @@ void MediaServerList::parseNewServer( IXML_Document *doc, const std::string &loc
break;
p_server->isSatIp = true;
- if ( !addServerLocked( p_server ) )
+ if ( !addServer( p_server ) )
delete p_server;
} else {
/* if no playlist is found, add a playlist from the web based on the chosen
@@ -490,7 +487,7 @@ void MediaServerList::parseNewServer( IXML_Document *doc, const std::string &loc
psz_friendly_name, psz_url, iconUrl );
p_server->isSatIp = true;
- if( !addServerLocked( p_server ) ) {
+ if( !addServer( p_server ) ) {
delete p_server;
}
free( psz_url );
@@ -539,7 +536,7 @@ void MediaServerList::parseNewServer( IXML_Document *doc, const std::string &loc
if ( unlikely( !p_server ) )
break;
- if ( !addServerLocked( p_server ) )
+ if ( !addServer( p_server ) )
{
delete p_server;
continue;
@@ -610,9 +607,7 @@ std::string MediaServerList::getIconURL( IXML_Element* p_device_elem, const char
void MediaServerList::removeServer( const std::string& udn )
{
- vlc_mutex_locker lock( &m_lock );
-
- MediaServerDesc* p_server = getServerLocked( udn );
+ MediaServerDesc* p_server = getServer( udn );
if ( !p_server )
return;
diff --git a/modules/services_discovery/upnp.hpp b/modules/services_discovery/upnp.hpp
index f30dfeb..bfbf261 100644
--- a/modules/services_discovery/upnp.hpp
+++ b/modules/services_discovery/upnp.hpp
@@ -100,9 +100,9 @@ public:
MediaServerList( services_discovery_t* p_sd );
~MediaServerList();
- bool addServerLocked(MediaServerDesc *desc );
+ bool addServer(MediaServerDesc *desc );
void removeServer(const std::string &udn );
- MediaServerDesc* getServerLocked( const std::string& udn );
+ MediaServerDesc* getServer( const std::string& udn );
static int Callback( Upnp_EventType event_type, void* p_event, MediaServerList* self );
private:
@@ -112,7 +112,6 @@ private:
private:
services_discovery_t* const m_sd;
std::vector<MediaServerDesc*> m_list;
- vlc_mutex_t m_lock;
};
}
More information about the vlc-commits
mailing list