X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fplaylist%2Fservices_discovery.c;h=1155779385b3b5d448cef2d4a0eb1ccde06a4c1b;hb=56c70401a28856211bc0021841179f5edc392c6f;hp=c9f9aff4377c831badd7a3331e0d1b3c6f4821c8;hpb=350b1052769f273c46b29d1ba60e2caa9c925ecb;p=vlc diff --git a/src/playlist/services_discovery.c b/src/playlist/services_discovery.c index c9f9aff437..1155779385 100644 --- a/src/playlist/services_discovery.c +++ b/src/playlist/services_discovery.c @@ -55,15 +55,6 @@ int vlc_sd_probe_Add (vlc_probe_t *probe, const char *name, return VLC_PROBE_CONTINUE; } -struct vlc_sd_private_t -{ - module_t * p_module; - vlc_event_manager_t event_manager; /* Accessed through Setters for non class function */ - char *psz_name; - config_chain_t *p_cfg; - -}; - #undef vlc_sd_GetNames /** @@ -123,11 +114,9 @@ services_discovery_t *vlc_sd_Create( vlc_object_t *p_super, "services discovery" ); if( !p_sd ) return NULL; - p_sd->p = malloc(sizeof(struct vlc_sd_private_t)); - - free(config_ChainCreate( &p_sd->p->psz_name, &p_sd->p->p_cfg, cfg )); + free(config_ChainCreate( &p_sd->psz_name, &p_sd->p_cfg, cfg )); - vlc_event_manager_t *em = &p_sd->p->event_manager; + vlc_event_manager_t *em = &p_sd->event_manager; vlc_event_manager_init( em, p_sd, (vlc_object_t *)p_sd ); vlc_event_manager_register_event_type(em, vlc_ServicesDiscoveryItemAdded); vlc_event_manager_register_event_type(em, vlc_ServicesDiscoveryItemRemoved); @@ -147,9 +136,9 @@ bool vlc_sd_Start ( services_discovery_t * p_sd ) { assert(!p_sd->p_module); - p_sd->p->p_module = module_need( p_sd, "services_discovery", - p_sd->p->psz_name, true ); - if( p_sd->p->p_module == NULL ) + p_sd->p_module = module_need( p_sd, "services_discovery", + p_sd->psz_name, true ); + if( p_sd->p_module == NULL ) { msg_Err( p_sd, "no suitable services discovery module" ); return false; @@ -158,7 +147,7 @@ bool vlc_sd_Start ( services_discovery_t * p_sd ) vlc_event_t event = { .type = vlc_ServicesDiscoveryStarted }; - vlc_event_send( &p_sd->p->event_manager, &event ); + vlc_event_send( &p_sd->event_manager, &event ); return true; } @@ -171,17 +160,16 @@ void vlc_sd_Stop ( services_discovery_t * p_sd ) .type = vlc_ServicesDiscoveryEnded }; - vlc_event_send( &p_sd->p->event_manager, &event ); + vlc_event_send( &p_sd->event_manager, &event ); - module_unneed( p_sd, p_sd->p->p_module ); - p_sd->p->p_module = NULL; + module_unneed( p_sd, p_sd->p_module ); + p_sd->p_module = NULL; } void vlc_sd_Destroy( services_discovery_t *p_sd ) { - config_ChainDestroy( p_sd->p->p_cfg ); - free( p_sd->p->psz_name ); - free( p_sd->p ); + config_ChainDestroy( p_sd->p_cfg ); + free( p_sd->psz_name ); vlc_object_release( p_sd ); } @@ -191,8 +179,8 @@ void vlc_sd_Destroy( services_discovery_t *p_sd ) static void services_discovery_Destructor ( vlc_object_t *p_obj ) { services_discovery_t * p_sd = (services_discovery_t *)p_obj; - assert(!p_sd->p->p_module); /* Forgot to call Stop */ - vlc_event_manager_fini( &p_sd->p->event_manager ); + assert(!p_sd->p_module); /* Forgot to call Stop */ + vlc_event_manager_fini( &p_sd->event_manager ); } /*********************************************************************** @@ -201,7 +189,7 @@ static void services_discovery_Destructor ( vlc_object_t *p_obj ) char * services_discovery_GetLocalizedName ( services_discovery_t * p_sd ) { - return strdup( module_get_name( p_sd->p->p_module, true ) ); + return strdup( module_get_name( p_sd->p_module, true ) ); } /*********************************************************************** @@ -210,7 +198,7 @@ services_discovery_GetLocalizedName ( services_discovery_t * p_sd ) vlc_event_manager_t * services_discovery_EventManager ( services_discovery_t * p_sd ) { - return &p_sd->p->event_manager; + return &p_sd->event_manager; } /*********************************************************************** @@ -225,7 +213,7 @@ services_discovery_AddItem ( services_discovery_t * p_sd, input_item_t * p_item, event.u.services_discovery_item_added.p_new_item = p_item; event.u.services_discovery_item_added.psz_category = psz_category; - vlc_event_send( &p_sd->p->event_manager, &event ); + vlc_event_send( &p_sd->event_manager, &event ); } /*********************************************************************** @@ -238,14 +226,14 @@ services_discovery_RemoveItem ( services_discovery_t * p_sd, input_item_t * p_it event.type = vlc_ServicesDiscoveryItemRemoved; event.u.services_discovery_item_removed.p_item = p_item; - vlc_event_send( &p_sd->p->event_manager, &event ); + vlc_event_send( &p_sd->event_manager, &event ); } /* * Playlist - Services discovery bridge */ -struct vlc_playlist_sd_t +struct vlc_sd_internal_t { /* the playlist items for category and onelevel */ playlist_item_t *p_node; @@ -275,7 +263,7 @@ static void playlist_sd_item_added( const vlc_event_t * p_event, void * user_dat if( !p_cat ) { p_cat = playlist_NodeCreate( p_playlist, psz_cat, - p_parent, 0, NULL ); + p_parent, PLAYLIST_END, 0, NULL ); p_cat->i_flags &= ~PLAYLIST_SKIP_FLAG; } p_parent = p_cat; @@ -324,7 +312,7 @@ int playlist_ServicesDiscoveryAdd( playlist_t *p_playlist, return VLC_ENOMEM; /* Free in playlist_ServicesDiscoveryRemove */ - vlc_playlist_sd_t * p_sds = malloc( sizeof(*p_sds) ); + vlc_sd_internal_t * p_sds = malloc( sizeof(*p_sds) ); if( !p_sds ) { vlc_sd_Destroy( p_sd ); @@ -335,9 +323,9 @@ int playlist_ServicesDiscoveryAdd( playlist_t *p_playlist, /* Look for configuration chain "longname" */ const char *psz_longname = "?"; - if( p_sd->p->p_cfg ) + if( p_sd->p_cfg ) { - config_chain_t *cfg = p_sd->p->p_cfg; + config_chain_t *cfg = p_sd->p_cfg; while( cfg ) { if( cfg->psz_name && !strcmp( cfg->psz_name, "longname" ) ) @@ -351,7 +339,7 @@ int playlist_ServicesDiscoveryAdd( playlist_t *p_playlist, PL_LOCK; p_node = playlist_NodeCreate( p_playlist, psz_longname, - p_playlist->p_root, 0, NULL ); + p_playlist->p_root, PLAYLIST_END, 0, NULL ); PL_UNLOCK; vlc_event_manager_t *em = services_discovery_EventManager( p_sd ); @@ -368,8 +356,6 @@ int playlist_ServicesDiscoveryAdd( playlist_t *p_playlist, return VLC_EGENERIC; } - /* We want tree-view for service directory */ - p_node->p_input->b_prefers_tree = true; p_sds->p_sd = p_sd; p_sds->p_node = p_node; p_sds->psz_name = strdup( psz_name ); @@ -385,7 +371,7 @@ int playlist_ServicesDiscoveryRemove( playlist_t * p_playlist, const char *psz_name ) { playlist_private_t *priv = pl_priv( p_playlist ); - vlc_playlist_sd_t * p_sds = NULL; + vlc_sd_internal_t * p_sds = NULL; PL_LOCK; for( int i = 0; i < priv->i_sds; i++ ) @@ -441,7 +427,7 @@ bool playlist_IsServicesDiscoveryLoaded( playlist_t * p_playlist, for( int i = 0; i < priv->i_sds; i++ ) { - vlc_playlist_sd_t *sd = priv->pp_sds[i]; + vlc_sd_internal_t *sd = priv->pp_sds[i]; if( sd->psz_name && !strcmp( psz_name, sd->psz_name ) ) {