Commit d3b42e43 authored by Rafaël Carré's avatar Rafaël Carré

services_discovery: storing the category & onelevel playlist items with the...

services_discovery: storing the category & onelevel playlist items with the services_discovery_t is not needed anymore, simplify that.
put the services_discovery_t** in the public playlist_t to save one unchecked malloc() and the corresponding free()
parent 884e2a4e
......@@ -180,7 +180,10 @@ struct services_discovery_t
struct playlist_t
{
VLC_COMMON_MEMBERS
struct playlist_internal_t * p_internal; /**< Internal members */
/* pp_sd & i_sd are for internal use ONLY. Understood ? it's PRIVATE ! */
services_discovery_t **pp_sd; /**< Loaded service discovery modules */
int i_sd; /**< Number of service discovery modules */
int i_enabled; /**< How many items are enabled ? */
......
......@@ -66,8 +66,7 @@ playlist_t * playlist_Create( vlc_object_t *p_parent )
return NULL;
}
p_playlist->p_internal = malloc(sizeof(struct playlist_internal_t));
memset( p_playlist->p_internal, 0, sizeof(struct playlist_internal_t) );
TAB_INIT( p_playlist->i_sd, p_playlist->pp_sd );
p_parent->p_libvlc->p_playlist = p_playlist;
......@@ -178,7 +177,6 @@ void playlist_Destroy( playlist_t *p_playlist )
vlc_mutex_destroy( &p_playlist->gc_lock );
vlc_object_detach( p_playlist );
free( p_playlist->p_internal );
vlc_object_destroy( p_playlist );
}
......@@ -439,10 +437,10 @@ void playlist_LastLoop( playlist_t *p_playlist )
vout_Destroy( (vout_thread_t *)p_obj );
}
while( p_playlist->p_internal->i_asds )
while( p_playlist->i_sd )
{
playlist_ServicesDiscoveryRemove( p_playlist,
p_playlist->p_internal->pp_asds[0]->p_sd->psz_module );
p_playlist->pp_sd[0]->psz_module );
}
playlist_MLDump( p_playlist );
......
......@@ -58,19 +58,6 @@ struct playlist_fetcher_t
DECL_ARRAY(playlist_album_t) albums;
};
typedef struct playlist_archived_services_discovery_t {
services_discovery_t * p_sd; /* The service discovery module */
playlist_item_t * p_cat;/* Corresponding item in the category view */
playlist_item_t * p_one;/* Corresponding item in the one level view */
} playlist_archived_services_discovery_t;
struct playlist_internal_t {
struct playlist_archived_services_discovery_t
**pp_asds; /**< Loaded service discovery modules */
int i_asds; /**< Number of service discovery modules */
};
/*****************************************************************************
* Prototypes
*****************************************************************************/
......
......@@ -303,14 +303,8 @@ int playlist_ServicesDiscoveryAdd( playlist_t *p_playlist, const char *psz_modu
services_discovery_Start( p_sd );
/* Free in playlist_ServicesDiscoveryRemove */
p_asd = malloc( sizeof(struct playlist_archived_services_discovery_t) );
p_asd->p_sd = p_sd;
p_asd->p_one = p_one;
p_asd->p_cat = p_cat;
PL_LOCK;
TAB_APPEND( p_playlist->p_internal->i_asds, p_playlist->p_internal->pp_asds, p_asd );
TAB_APPEND( p_playlist->i_sd, p_playlist->pp_sd, p_sd );
PL_UNLOCK;
}
......@@ -321,63 +315,60 @@ int playlist_ServicesDiscoveryRemove( playlist_t * p_playlist,
const char *psz_module )
{
int i;
struct playlist_archived_services_discovery_t *p_asd = NULL;
struct services_discovery_t *p_sd = NULL;
PL_LOCK;
for( i = 0 ; i< p_playlist->p_internal->i_asds ; i ++ )
for( i = 0 ; i< p_playlist->i_sd ; i ++ )
{
if( !strcmp( psz_module, p_playlist->p_internal->pp_asds[i]->p_sd->psz_module ) )
if( !strcmp( psz_module, p_playlist->pp_sd[i]->psz_module ) )
{
p_asd = p_playlist->p_internal->pp_asds[i];
REMOVE_ELEM( p_playlist->p_internal->pp_asds, p_playlist->p_internal->i_asds, i );
p_sd = p_playlist->pp_sd[i];
REMOVE_ELEM( p_playlist->pp_sd, p_playlist->i_sd, i );
break;
}
}
PL_UNLOCK;
if( p_asd && p_asd->p_sd )
if( p_sd == NULL )
{
services_discovery_Stop( p_asd->p_sd );
vlc_event_detach( services_discovery_EventManager( p_asd->p_sd ),
vlc_ServicesDiscoveryItemAdded,
playlist_sd_item_added,
p_asd->p_one );
msg_Warn( p_playlist, "module %s is not loaded", psz_module );
return VLC_EGENERIC;
}
vlc_event_detach( services_discovery_EventManager( p_asd->p_sd ),
vlc_ServicesDiscoveryItemAdded,
playlist_sd_item_added,
p_asd->p_cat );
services_discovery_Stop( p_sd );
vlc_event_detach( services_discovery_EventManager( p_asd->p_sd ),
vlc_ServicesDiscoveryItemRemoved,
playlist_sd_item_removed,
p_asd->p_one );
vlc_event_detach( services_discovery_EventManager( p_sd ),
vlc_ServicesDiscoveryItemAdded,
playlist_sd_item_added,
p_sd->p_one );
vlc_event_detach( services_discovery_EventManager( p_asd->p_sd ),
vlc_ServicesDiscoveryItemRemoved,
playlist_sd_item_removed,
p_asd->p_cat );
vlc_event_detach( services_discovery_EventManager( p_sd ),
vlc_ServicesDiscoveryItemAdded,
playlist_sd_item_added,
p_sd->p_cat );
/* Remove the sd playlist node if it exists */
PL_LOCK;
if( p_asd->p_cat != p_playlist->p_root_category &&
p_asd->p_one != p_playlist->p_root_onelevel )
{
playlist_NodeDelete( p_playlist, p_asd->p_cat, VLC_TRUE, VLC_FALSE );
playlist_NodeDelete( p_playlist, p_asd->p_one, VLC_TRUE, VLC_FALSE );
}
PL_UNLOCK;
vlc_event_detach( services_discovery_EventManager( p_sd ),
vlc_ServicesDiscoveryItemRemoved,
playlist_sd_item_removed,
p_sd->p_one );
services_discovery_Destroy( p_asd->p_sd );
vlc_event_detach( services_discovery_EventManager( p_sd ),
vlc_ServicesDiscoveryItemRemoved,
playlist_sd_item_removed,
p_sd->p_cat );
free( p_asd );
}
else
/* Remove the sd playlist node if it exists */
PL_LOCK;
if( p_sd->p_cat != p_playlist->p_root_category &&
p_sd->p_one != p_playlist->p_root_onelevel )
{
msg_Warn( p_playlist, "module %s is not loaded", psz_module );
return VLC_EGENERIC;
playlist_NodeDelete( p_playlist, p_sd->p_cat, VLC_TRUE, VLC_FALSE );
playlist_NodeDelete( p_playlist, p_sd->p_one, VLC_TRUE, VLC_FALSE );
}
PL_UNLOCK;
services_discovery_Destroy( p_sd );
return VLC_SUCCESS;
}
......@@ -387,9 +378,9 @@ vlc_bool_t playlist_IsServicesDiscoveryLoaded( playlist_t * p_playlist,
int i;
PL_LOCK;
for( i = 0 ; i< p_playlist->p_internal->i_asds ; i ++ )
for( i = 0 ; i< p_playlist->i_sd ; i ++ )
{
if( !strcmp( psz_module, p_playlist->p_internal->pp_asds[i]->p_sd->psz_module ) )
if( !strcmp( psz_module, p_playlist->pp_sd[i]->psz_module ) )
{
PL_UNLOCK;
return VLC_TRUE;
......
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