Commit e9dea57b authored by Steve Lhomme's avatar Steve Lhomme Committed by Jean-Baptiste Kempf

chromecast: only lock once when checking the current app

Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
parent b84d8384
...@@ -276,21 +276,23 @@ void intf_sys_t::processMessage(const castchannel::CastMessage &msg) ...@@ -276,21 +276,23 @@ void intf_sys_t::processMessage(const castchannel::CastMessage &msg)
{ {
json_value applications = (*p_data)["status"]["applications"]; json_value applications = (*p_data)["status"]["applications"];
const json_value *p_app = NULL; const json_value *p_app = NULL;
vlc_mutex_locker locker(&lock);
for (unsigned i = 0; i < applications.u.array.length; ++i) for (unsigned i = 0; i < applications.u.array.length; ++i)
{ {
std::string appId(applications[i]["appId"]); std::string appId(applications[i]["appId"]);
if (appId == APP_ID) if (appId == APP_ID)
{ {
const char *pz_transportId = applications[i]["transportId"];
if (pz_transportId != NULL)
{
appTransportId = std::string(pz_transportId);
p_app = &applications[i]; p_app = &applications[i];
vlc_mutex_lock(&lock); }
if (appTransportId.empty())
appTransportId = std::string(applications[i]["transportId"]);
vlc_mutex_unlock(&lock);
break; break;
} }
} }
vlc_mutex_lock(&lock);
if ( p_app ) if ( p_app )
{ {
if (!appTransportId.empty() if (!appTransportId.empty()
...@@ -318,7 +320,6 @@ void intf_sys_t::processMessage(const castchannel::CastMessage &msg) ...@@ -318,7 +320,6 @@ void intf_sys_t::processMessage(const castchannel::CastMessage &msg)
} }
} }
vlc_mutex_unlock(&lock);
} }
else else
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment