[vlc-devel] [PATCH 3/3] service_discovery: Consistently use PL_LOCK/PL_UNLOCK

Henk Visser mrhenkvisser at gmail.com
Tue Jul 25 19:06:58 CEST 2017


unsubscribe



On Tue, Jul 25, 2017 at 9:48 AM, Marvin Scholz <epirat07 at gmail.com> wrote:

> ---
>  src/playlist/services_discovery.c | 48 +++++++++++++++++++-----------
> ---------
>  1 file changed, 24 insertions(+), 24 deletions(-)
>
> diff --git a/src/playlist/services_discovery.c b/src/playlist/services_
> discovery.c
> index d041c728b2..019c47e806 100644
> --- a/src/playlist/services_discovery.c
> +++ b/src/playlist/services_discovery.c
> @@ -46,19 +46,19 @@ static void playlist_sd_item_added(services_discovery_t
> *sd,
>      assert(parent == NULL || psz_cat == NULL);
>
>      vlc_sd_internal_t *sds = sd->owner.sys;
> -    playlist_t *playlist = (playlist_t *)sd->obj.parent;
> +    playlist_t *p_playlist = (playlist_t *)sd->obj.parent;
>      playlist_item_t *node;
>      const char *longname = (sd->description != NULL) ? sd->description :
> "?";
>
>      msg_Dbg(sd, "adding sd item: %s", p_input->psz_name ?
> p_input->psz_name : "(null)");
>
> -    playlist_Lock(playlist);
> +    PL_LOCK;
>      if (sds->node == NULL)
> -        sds->node = playlist_NodeCreate(playlist, longname,
> &playlist->root,
> +        sds->node = playlist_NodeCreate(p_playlist, longname,
> &p_playlist->root,
>                                          PLAYLIST_END, PLAYLIST_RO_FLAG);
>
>      if (parent != NULL)
> -        node = playlist_ItemGetByInput(playlist, parent);
> +        node = playlist_ItemGetByInput(p_playlist, parent);
>      else
>      if (psz_cat == NULL)
>          node = sds->node;
> @@ -67,12 +67,12 @@ static void playlist_sd_item_added(services_discovery_t
> *sd,
>           * This is clearly a hack. TODO: remove this. */
>          node = playlist_ChildSearchName(sds->node, psz_cat);
>          if (node == NULL)
> -            node = playlist_NodeCreate(playlist, psz_cat, sds->node,
> +            node = playlist_NodeCreate(p_playlist, psz_cat, sds->node,
>                                         PLAYLIST_END, PLAYLIST_RO_FLAG);
>      }
>
> -    playlist_NodeAddInput(playlist, p_input, node, PLAYLIST_END);
> -    playlist_Unlock(playlist);
> +    playlist_NodeAddInput(p_playlist, p_input, node, PLAYLIST_END);
> +    PL_UNLOCK;
>  }
>
>   /* A new item has been removed from a certain sd */
> @@ -110,7 +110,7 @@ static void playlist_sd_item_removed(services_discovery_t
> *sd,
>      PL_UNLOCK;
>  }
>
> -int playlist_ServicesDiscoveryAdd(playlist_t *playlist, const char
> *chain)
> +int playlist_ServicesDiscoveryAdd(playlist_t *p_playlist, const char
> *chain)
>  {
>      vlc_sd_internal_t *sds = malloc(sizeof (*sds) + strlen(chain) + 1);
>      if (unlikely(sds == NULL))
> @@ -125,7 +125,7 @@ int playlist_ServicesDiscoveryAdd(playlist_t
> *playlist, const char *chain)
>      };
>
>      /* Perform the addition */
> -    sds->sd = vlc_sd_Create(VLC_OBJECT(playlist), chain, &owner);
> +    sds->sd = vlc_sd_Create(VLC_OBJECT(p_playlist), chain, &owner);
>      if (unlikely(sds->sd == NULL))
>      {
>          free(sds);
> @@ -134,42 +134,42 @@ int playlist_ServicesDiscoveryAdd(playlist_t
> *playlist, const char *chain)
>
>      strcpy(sds->name, chain);
>
> -    playlist_Lock(playlist);
> +    PL_LOCK;
>      /* Backward compatibility with Qt UI: create the node even if the SD
>       * has not discovered any item. */
>      if (sds->node == NULL && sds->sd->description != NULL)
> -        sds->node = playlist_NodeCreate(playlist, sds->sd->description,
> -                                        &playlist->root, PLAYLIST_END,
> +        sds->node = playlist_NodeCreate(p_playlist, sds->sd->description,
> +                                        &p_playlist->root, PLAYLIST_END,
>                                          PLAYLIST_RO_FLAG);
>
> -    TAB_APPEND(pl_priv(playlist)->i_sds, pl_priv(playlist)->pp_sds, sds);
> -    playlist_Unlock(playlist);
> +    TAB_APPEND(pl_priv(p_playlist)->i_sds, pl_priv(p_playlist)->pp_sds,
> sds);
> +    PL_UNLOCK;
>      return VLC_SUCCESS;
>  }
>
> -static void playlist_ServicesDiscoveryInternalRemove(playlist_t
> *playlist,
> +static void playlist_ServicesDiscoveryInternalRemove(playlist_t
> *p_playlist,
>                                                       vlc_sd_internal_t
> *sds)
>  {
>      assert(sds->sd != NULL);
>      vlc_sd_Destroy(sds->sd);
>
>      /* Remove the sd playlist node if it exists */
> -    playlist_Lock(playlist);
> +    PL_LOCK;
>      if (sds->node != NULL)
> -        playlist_NodeDeleteExplicit(playlist, sds->node,
> +        playlist_NodeDeleteExplicit(p_playlist, sds->node,
>              PLAYLIST_DELETE_FORCE | PLAYLIST_DELETE_STOP_IF_CURRENT );
> -    playlist_Unlock(playlist);
> +    PL_UNLOCK;
>
>      free(sds);
>  }
>
>
> -int playlist_ServicesDiscoveryRemove(playlist_t *playlist, const char
> *name)
> +int playlist_ServicesDiscoveryRemove(playlist_t *p_playlist, const char
> *name)
>  {
> -    playlist_private_t *priv = pl_priv(playlist);
> +    playlist_private_t *priv = pl_priv(p_playlist);
>      vlc_sd_internal_t *sds = NULL;
>
> -    playlist_Lock(playlist);
> +    PL_LOCK;
>      for (int i = 0; i < priv->i_sds; i++)
>      {
>          vlc_sd_internal_t *entry = priv->pp_sds[i];
> @@ -181,15 +181,15 @@ int playlist_ServicesDiscoveryRemove(playlist_t
> *playlist, const char *name)
>              break;
>          }
>      }
> -    playlist_Unlock(playlist);
> +    PL_UNLOCK;
>
>      if (sds == NULL)
>      {
> -        msg_Warn(playlist, "discovery %s is not loaded", name);
> +        msg_Warn(p_playlist, "discovery %s is not loaded", name);
>          return VLC_EGENERIC;
>      }
>
> -    playlist_ServicesDiscoveryInternalRemove(playlist, sds);
> +    playlist_ServicesDiscoveryInternalRemove(p_playlist, sds);
>      return VLC_SUCCESS;
>  }
>
> --
> 2.11.0 (Apple Git-81)
>
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20170725/0d604fe7/attachment-0001.html>


More information about the vlc-devel mailing list