Commit f45691bd authored by Rémi Duraffort's avatar Rémi Duraffort

sout_announce: use a static mutex instead of a variable.

parent fd3aa03e
......@@ -49,6 +49,9 @@ static void sap_destroy (vlc_object_t *p_this)
}
#undef sout_AnnounceRegisterSDP
static vlc_mutex_t sap_mutex = VLC_STATIC_MUTEX;
/**
* Registers a new session with the announce handler, using a pregenerated SDP
*
......@@ -81,12 +84,7 @@ sout_AnnounceRegisterSDP( vlc_object_t *obj, const char *psz_sdp,
vlc_freeaddrinfo (res);
}
vlc_value_t lockval;
if (var_Create (obj->p_libvlc, "sap_mutex", VLC_VAR_MUTEX)
|| var_Get (obj->p_libvlc, "sap_mutex", &lockval))
goto error;
vlc_mutex_lock (lockval.p_address);
vlc_mutex_lock (&sap_mutex);
sap_handler_t *p_sap = libvlc_priv (obj->p_libvlc)->p_sap;
if (p_sap == NULL)
{
......@@ -96,7 +94,7 @@ sout_AnnounceRegisterSDP( vlc_object_t *obj, const char *psz_sdp,
}
else
vlc_object_hold ((vlc_object_t *)p_sap);
vlc_mutex_unlock (lockval.p_address);
vlc_mutex_unlock (&sap_mutex);
if (p_sap == NULL)
goto error;
......@@ -127,12 +125,9 @@ int sout_AnnounceUnRegister( vlc_object_t *obj,
msg_Dbg (obj, "removing SAP session");
SAP_Del (p_sap, p_session);
vlc_value_t lockval;
var_Create (obj->p_libvlc, "sap_mutex", VLC_VAR_MUTEX);
var_Get (obj->p_libvlc, "sap_mutex", &lockval);
vlc_mutex_lock (lockval.p_address);
vlc_mutex_lock (&sap_mutex);
vlc_object_release ((vlc_object_t *)p_sap);
vlc_mutex_unlock (lockval.p_address);
vlc_mutex_unlock (&sap_mutex);
free (p_session->psz_sdp);
free (p_session);
......
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