Changeset d3b42e438a49b7df4912c9f0db365b9355b93462
- Timestamp:
- 11/10/07 01:04:09
(1 year ago)
- Author:
- Rafaël Carré <funman@videolan.org>
- git-committer:
- Rafaël Carré <funman@videolan.org> 1192057449 +0000
- git-parent:
[884e2a4e4ffac2249258648ce8e9270c4d42152e]
- git-author:
- Rafaël Carré <funman@videolan.org> 1192057449 +0000
- Message:
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()
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r83a9495 |
rd3b42e4 |
|
| 181 | 181 | { |
|---|
| 182 | 182 | VLC_COMMON_MEMBERS |
|---|
| 183 | | struct playlist_internal_t * p_internal; /**< Internal members */ |
|---|
| | 183 | |
|---|
| | 184 | /* pp_sd & i_sd are for internal use ONLY. Understood ? it's PRIVATE ! */ |
|---|
| | 185 | services_discovery_t **pp_sd; /**< Loaded service discovery modules */ |
|---|
| | 186 | int i_sd; /**< Number of service discovery modules */ |
|---|
| 184 | 187 | |
|---|
| 185 | 188 | int i_enabled; /**< How many items are enabled ? */ |
|---|
| rc1f6dc8 |
rd3b42e4 |
|
| 67 | 67 | } |
|---|
| 68 | 68 | |
|---|
| 69 | | p_playlist->p_internal = malloc(sizeof(struct playlist_internal_t)); |
|---|
| 70 | | memset( p_playlist->p_internal, 0, sizeof(struct playlist_internal_t) ); |
|---|
| | 69 | TAB_INIT( p_playlist->i_sd, p_playlist->pp_sd ); |
|---|
| 71 | 70 | |
|---|
| 72 | 71 | p_parent->p_libvlc->p_playlist = p_playlist; |
|---|
| … | … | |
| 179 | 178 | vlc_mutex_destroy( &p_playlist->gc_lock ); |
|---|
| 180 | 179 | vlc_object_detach( p_playlist ); |
|---|
| 181 | | free( p_playlist->p_internal ); |
|---|
| 182 | 180 | vlc_object_destroy( p_playlist ); |
|---|
| 183 | 181 | } |
|---|
| … | … | |
| 440 | 438 | } |
|---|
| 441 | 439 | |
|---|
| 442 | | while( p_playlist->p_internal->i_asds ) |
|---|
| | 440 | while( p_playlist->i_sd ) |
|---|
| 443 | 441 | { |
|---|
| 444 | 442 | playlist_ServicesDiscoveryRemove( p_playlist, |
|---|
| 445 | | p_playlist->p_internal->pp_asds[0]->p_sd->psz_module ); |
|---|
| | 443 | p_playlist->pp_sd[0]->psz_module ); |
|---|
| 446 | 444 | } |
|---|
| 447 | 445 | |
|---|
| r02e8a6c |
rd3b42e4 |
|
| 58 | 58 | DECL_ARRAY(playlist_album_t) albums; |
|---|
| 59 | 59 | }; |
|---|
| 60 | | |
|---|
| 61 | | typedef struct playlist_archived_services_discovery_t { |
|---|
| 62 | | services_discovery_t * p_sd; /* The service discovery module */ |
|---|
| 63 | | playlist_item_t * p_cat;/* Corresponding item in the category view */ |
|---|
| 64 | | playlist_item_t * p_one;/* Corresponding item in the one level view */ |
|---|
| 65 | | } playlist_archived_services_discovery_t; |
|---|
| 66 | | |
|---|
| 67 | | struct playlist_internal_t { |
|---|
| 68 | | struct playlist_archived_services_discovery_t |
|---|
| 69 | | **pp_asds; /**< Loaded service discovery modules */ |
|---|
| 70 | | int i_asds; /**< Number of service discovery modules */ |
|---|
| 71 | | }; |
|---|
| 72 | | |
|---|
| 73 | 60 | |
|---|
| 74 | 61 | /***************************************************************************** |
|---|
| r83a9495 |
rd3b42e4 |
|
| 304 | 304 | services_discovery_Start( p_sd ); |
|---|
| 305 | 305 | |
|---|
| 306 | | /* Free in playlist_ServicesDiscoveryRemove */ |
|---|
| 307 | | p_asd = malloc( sizeof(struct playlist_archived_services_discovery_t) ); |
|---|
| 308 | | p_asd->p_sd = p_sd; |
|---|
| 309 | | p_asd->p_one = p_one; |
|---|
| 310 | | p_asd->p_cat = p_cat; |
|---|
| 311 | | |
|---|
| 312 | 306 | PL_LOCK; |
|---|
| 313 | | TAB_APPEND( p_playlist->p_internal->i_asds, p_playlist->p_internal->pp_asds, p_asd ); |
|---|
| | 307 | TAB_APPEND( p_playlist->i_sd, p_playlist->pp_sd, p_sd ); |
|---|
| 314 | 308 | PL_UNLOCK; |
|---|
| 315 | 309 | } |
|---|
| … | … | |
| 322 | 316 | { |
|---|
| 323 | 317 | int i; |
|---|
| 324 | | struct playlist_archived_services_discovery_t *p_asd = NULL; |
|---|
| | 318 | struct services_discovery_t *p_sd = NULL; |
|---|
| 325 | 319 | |
|---|
| 326 | 320 | PL_LOCK; |
|---|
| 327 | | for( i = 0 ; i< p_playlist->p_internal->i_asds ; i ++ ) |
|---|
| 328 | | { |
|---|
| 329 | | if( !strcmp( psz_module, p_playlist->p_internal->pp_asds[i]->p_sd->psz_module ) ) |
|---|
| 330 | | { |
|---|
| 331 | | p_asd = p_playlist->p_internal->pp_asds[i]; |
|---|
| 332 | | REMOVE_ELEM( p_playlist->p_internal->pp_asds, p_playlist->p_internal->i_asds, i ); |
|---|
| | 321 | for( i = 0 ; i< p_playlist->i_sd ; i ++ ) |
|---|
| | 322 | { |
|---|
| | 323 | if( !strcmp( psz_module, p_playlist->pp_sd[i]->psz_module ) ) |
|---|
| | 324 | { |
|---|
| | 325 | p_sd = p_playlist->pp_sd[i]; |
|---|
| | 326 | REMOVE_ELEM( p_playlist->pp_sd, p_playlist->i_sd, i ); |
|---|
| 333 | 327 | break; |
|---|
| 334 | 328 | } |
|---|
| … | … | |
| 336 | 330 | PL_UNLOCK; |
|---|
| 337 | 331 | |
|---|
| 338 | | if( p_asd && p_asd->p_sd ) |
|---|
| 339 | | { |
|---|
| 340 | | services_discovery_Stop( p_asd->p_sd ); |
|---|
| 341 | | |
|---|
| 342 | | vlc_event_detach( services_discovery_EventManager( p_asd->p_sd ), |
|---|
| 343 | | vlc_ServicesDiscoveryItemAdded, |
|---|
| 344 | | playlist_sd_item_added, |
|---|
| 345 | | p_asd->p_one ); |
|---|
| 346 | | |
|---|
| 347 | | vlc_event_detach( services_discovery_EventManager( p_asd->p_sd ), |
|---|
| 348 | | vlc_ServicesDiscoveryItemAdded, |
|---|
| 349 | | playlist_sd_item_added, |
|---|
| 350 | | p_asd->p_cat ); |
|---|
| 351 | | |
|---|
| 352 | | vlc_event_detach( services_discovery_EventManager( p_asd->p_sd ), |
|---|
| 353 | | vlc_ServicesDiscoveryItemRemoved, |
|---|
| 354 | | playlist_sd_item_removed, |
|---|
| 355 | | p_asd->p_one ); |
|---|
| 356 | | |
|---|
| 357 | | vlc_event_detach( services_discovery_EventManager( p_asd->p_sd ), |
|---|
| 358 | | vlc_ServicesDiscoveryItemRemoved, |
|---|
| 359 | | playlist_sd_item_removed, |
|---|
| 360 | | p_asd->p_cat ); |
|---|
| 361 | | |
|---|
| 362 | | /* Remove the sd playlist node if it exists */ |
|---|
| 363 | | PL_LOCK; |
|---|
| 364 | | if( p_asd->p_cat != p_playlist->p_root_category && |
|---|
| 365 | | p_asd->p_one != p_playlist->p_root_onelevel ) |
|---|
| 366 | | { |
|---|
| 367 | | playlist_NodeDelete( p_playlist, p_asd->p_cat, VLC_TRUE, VLC_FALSE ); |
|---|
| 368 | | playlist_NodeDelete( p_playlist, p_asd->p_one, VLC_TRUE, VLC_FALSE ); |
|---|
| 369 | | } |
|---|
| 370 | | PL_UNLOCK; |
|---|
| 371 | | |
|---|
| 372 | | services_discovery_Destroy( p_asd->p_sd ); |
|---|
| 373 | | |
|---|
| 374 | | free( p_asd ); |
|---|
| 375 | | } |
|---|
| 376 | | else |
|---|
| | 332 | if( p_sd == NULL ) |
|---|
| 377 | 333 | { |
|---|
| 378 | 334 | msg_Warn( p_playlist, "module %s is not loaded", psz_module ); |
|---|
| 379 | 335 | return VLC_EGENERIC; |
|---|
| 380 | 336 | } |
|---|
| | 337 | |
|---|
| | 338 | services_discovery_Stop( p_sd ); |
|---|
| | 339 | |
|---|
| | 340 | vlc_event_detach( services_discovery_EventManager( p_sd ), |
|---|
| | 341 | vlc_ServicesDiscoveryItemAdded, |
|---|
| | 342 | playlist_sd_item_added, |
|---|
| | 343 | p_sd->p_one ); |
|---|
| | 344 | |
|---|
| | 345 | vlc_event_detach( services_discovery_EventManager( p_sd ), |
|---|
| | 346 | vlc_ServicesDiscoveryItemAdded, |
|---|
| | 347 | playlist_sd_item_added, |
|---|
| | 348 | p_sd->p_cat ); |
|---|
| | 349 | |
|---|
| | 350 | vlc_event_detach( services_discovery_EventManager( p_sd ), |
|---|
| | 351 | vlc_ServicesDiscoveryItemRemoved, |
|---|
| | 352 | playlist_sd_item_removed, |
|---|
| | 353 | p_sd->p_one ); |
|---|
| | 354 | |
|---|
| | 355 | vlc_event_detach( services_discovery_EventManager( p_sd ), |
|---|
| | 356 | vlc_ServicesDiscoveryItemRemoved, |
|---|
| | 357 | playlist_sd_item_removed, |
|---|
| | 358 | p_sd->p_cat ); |
|---|
| | 359 | |
|---|
| | 360 | /* Remove the sd playlist node if it exists */ |
|---|
| | 361 | PL_LOCK; |
|---|
| | 362 | if( p_sd->p_cat != p_playlist->p_root_category && |
|---|
| | 363 | p_sd->p_one != p_playlist->p_root_onelevel ) |
|---|
| | 364 | { |
|---|
| | 365 | playlist_NodeDelete( p_playlist, p_sd->p_cat, VLC_TRUE, VLC_FALSE ); |
|---|
| | 366 | playlist_NodeDelete( p_playlist, p_sd->p_one, VLC_TRUE, VLC_FALSE ); |
|---|
| | 367 | } |
|---|
| | 368 | PL_UNLOCK; |
|---|
| | 369 | |
|---|
| | 370 | services_discovery_Destroy( p_sd ); |
|---|
| | 371 | |
|---|
| 381 | 372 | return VLC_SUCCESS; |
|---|
| 382 | 373 | } |
|---|
| … | … | |
| 388 | 379 | PL_LOCK; |
|---|
| 389 | 380 | |
|---|
| 390 | | for( i = 0 ; i< p_playlist->p_internal->i_asds ; i ++ ) |
|---|
| 391 | | { |
|---|
| 392 | | if( !strcmp( psz_module, p_playlist->p_internal->pp_asds[i]->p_sd->psz_module ) ) |
|---|
| | 381 | for( i = 0 ; i< p_playlist->i_sd ; i ++ ) |
|---|
| | 382 | { |
|---|
| | 383 | if( !strcmp( psz_module, p_playlist->pp_sd[i]->psz_module ) ) |
|---|
| 393 | 384 | { |
|---|
| 394 | 385 | PL_UNLOCK; |
|---|