Commit 9882ff2e authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

sd: move callbacks to constant structure

parent a6e1e1b0
......@@ -40,14 +40,19 @@ extern "C" {
* @{
*/
struct services_discovery_owner_t
struct services_discovery_callbacks
{
void *sys; /**< Private data for the owner callbacks */
void (*item_added)(struct services_discovery_t *sd, input_item_t *parent,
input_item_t *item, const char *category);
void (*item_removed)(struct services_discovery_t *sd, input_item_t *item);
};
struct services_discovery_owner_t
{
const struct services_discovery_callbacks *cbs;
void *sys; /**< Private data for the owner callbacks */
};
/**
* Main service discovery structure to build a SD module
*/
......@@ -157,7 +162,7 @@ VLC_API void vlc_sd_Destroy( services_discovery_t * );
static inline void services_discovery_AddItem(services_discovery_t *sd,
input_item_t *item)
{
sd->owner.item_added(sd, NULL, item, NULL);
sd->owner.cbs->item_added(sd, NULL, item, NULL);
}
/**
......@@ -181,7 +186,7 @@ static inline void services_discovery_AddSubItem(services_discovery_t *sd,
input_item_t *parent,
input_item_t *item)
{
sd->owner.item_added(sd, parent, item, NULL);
sd->owner.cbs->item_added(sd, parent, item, NULL);
}
/**
......@@ -195,7 +200,7 @@ static inline void services_discovery_AddItemCat(services_discovery_t *sd,
input_item_t *item,
const char *category)
{
sd->owner.item_added(sd, NULL, item, category);
sd->owner.cbs->item_added(sd, NULL, item, category);
}
/**
......@@ -207,7 +212,7 @@ static inline void services_discovery_AddItemCat(services_discovery_t *sd,
static inline void services_discovery_RemoveItem(services_discovery_t *sd,
input_item_t *item)
{
sd->owner.item_removed(sd, item);
sd->owner.cbs->item_removed(sd, item);
}
/* SD probing */
......
......@@ -169,6 +169,11 @@ libvlc_media_discoverer_new( libvlc_instance_t * p_inst, const char * psz_name )
return p_mdis;
}
static const struct services_discovery_callbacks sd_cbs = {
.item_added = services_discovery_item_added,
.item_removed = services_discovery_item_removed,
};
/**************************************************************************
* start (Public)
**************************************************************************/
......@@ -176,9 +181,8 @@ LIBVLC_API int
libvlc_media_discoverer_start( libvlc_media_discoverer_t * p_mdis )
{
struct services_discovery_owner_t owner = {
&sd_cbs,
p_mdis,
services_discovery_item_added,
services_discovery_item_removed,
};
/* Here we go */
......
......@@ -110,6 +110,11 @@ static void playlist_sd_item_removed(services_discovery_t *sd,
playlist_Unlock(playlist);
}
static const struct services_discovery_callbacks playlist_sd_cbs = {
.item_added = playlist_sd_item_added,
.item_removed = playlist_sd_item_removed,
};
int playlist_ServicesDiscoveryAdd(playlist_t *playlist, const char *chain)
{
vlc_sd_internal_t *sds = malloc(sizeof (*sds) + strlen(chain) + 1);
......@@ -119,9 +124,8 @@ int playlist_ServicesDiscoveryAdd(playlist_t *playlist, const char *chain)
sds->node = NULL;
struct services_discovery_owner_t owner = {
&playlist_sd_cbs,
sds,
playlist_sd_item_added,
playlist_sd_item_removed,
};
/* Perform the addition */
......
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