Changeset ace44bc9f59e2ced98bb8534aa225fce9a479d8b
- Timestamp:
- 15/07/08 09:40:39
(5 months ago)
- Author:
- Pierre d'Herbemont <pdherbemont@videolan.org>
- git-committer:
- Pierre d'Herbemont <pdherbemont@videolan.org> 1216107639 +0200
- git-parent:
[4d0721f0d1dcafd37dc6116e6b6e44a2d1b500f7]
- git-author:
- Pierre d'Herbemont <pdherbemont@videolan.org> 1216107639 +0200
- Message:
playlist: Use PL_LOCK_IF and PL_UNLOCK_IF to perform some more checks on lock state. And fix a unlocked usage of get_current_status_item().
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r7f717d6 |
race44bc |
|
| 66 | 66 | int i_result; |
|---|
| 67 | 67 | va_start( args, b_locked ); |
|---|
| 68 | | if( !b_locked ) PL_LOCK; |
|---|
| | 68 | PL_LOCK_IF( !b_locked ); |
|---|
| 69 | 69 | i_result = PlaylistVAControl( p_playlist, i_query, args ); |
|---|
| 70 | 70 | va_end( args ); |
|---|
| 71 | | if( !b_locked ) PL_UNLOCK; |
|---|
| | 71 | PL_UNLOCK_IF( !b_locked ); |
|---|
| 72 | 72 | |
|---|
| 73 | 73 | return i_result; |
|---|
| r7f717d6 |
race44bc |
|
| 257 | 257 | { |
|---|
| 258 | 258 | int i_ret; |
|---|
| 259 | | if( !b_locked ) PL_LOCK; |
|---|
| | 259 | PL_LOCK_IF( !b_locked ); |
|---|
| 260 | 260 | i_ret = DeleteFromInput( p_playlist, i_input_id, |
|---|
| 261 | 261 | p_root, true ); |
|---|
| 262 | | if( !b_locked ) PL_UNLOCK; |
|---|
| | 262 | PL_UNLOCK_IF( !b_locked ); |
|---|
| 263 | 263 | return i_ret; |
|---|
| 264 | 264 | } |
|---|
| … | … | |
| 277 | 277 | { |
|---|
| 278 | 278 | int i_ret1, i_ret2; |
|---|
| 279 | | if( !b_locked ) PL_LOCK; |
|---|
| | 279 | PL_LOCK_IF( !b_locked ); |
|---|
| 280 | 280 | i_ret1 = DeleteFromInput( p_playlist, i_input_id, |
|---|
| 281 | 281 | p_playlist->p_root_category, true ); |
|---|
| 282 | 282 | i_ret2 = DeleteFromInput( p_playlist, i_input_id, |
|---|
| 283 | 283 | p_playlist->p_root_onelevel, true ); |
|---|
| 284 | | if( !b_locked ) PL_UNLOCK; |
|---|
| | 284 | PL_UNLOCK_IF( !b_locked ); |
|---|
| 285 | 285 | return ( i_ret1 == VLC_SUCCESS || i_ret2 == VLC_SUCCESS ) ? |
|---|
| 286 | 286 | VLC_SUCCESS : VLC_ENOITEM; |
|---|
| … | … | |
| 296 | 296 | void playlist_Clear( playlist_t * p_playlist, bool b_locked ) |
|---|
| 297 | 297 | { |
|---|
| 298 | | if( !b_locked ) PL_LOCK; |
|---|
| | 298 | PL_LOCK_IF( !b_locked ); |
|---|
| 299 | 299 | playlist_NodeEmpty( p_playlist, p_playlist->p_local_category, true ); |
|---|
| 300 | 300 | playlist_NodeEmpty( p_playlist, p_playlist->p_local_onelevel, true ); |
|---|
| 301 | | if( !b_locked ) PL_UNLOCK; |
|---|
| | 301 | PL_UNLOCK_IF( !b_locked ); |
|---|
| 302 | 302 | } |
|---|
| 303 | 303 | |
|---|
| … | … | |
| 404 | 404 | p_input->psz_uri ); |
|---|
| 405 | 405 | |
|---|
| 406 | | if( !b_locked ) PL_LOCK; |
|---|
| | 406 | PL_LOCK_IF( !b_locked ); |
|---|
| 407 | 407 | |
|---|
| 408 | 408 | /* Add to ONELEVEL */ |
|---|
| … | … | |
| 422 | 422 | GoAndPreparse( p_playlist, i_mode, p_item_cat, p_item_one ); |
|---|
| 423 | 423 | |
|---|
| 424 | | if( !b_locked ) PL_UNLOCK; |
|---|
| | 424 | PL_UNLOCK_IF( !b_locked ); |
|---|
| 425 | 425 | return VLC_SUCCESS; |
|---|
| 426 | 426 | } |
|---|
| … | … | |
| 453 | 453 | assert( p_input ); |
|---|
| 454 | 454 | |
|---|
| 455 | | if( !b_locked ) PL_LOCK; |
|---|
| | 455 | PL_LOCK_IF( !b_locked ); |
|---|
| 456 | 456 | |
|---|
| 457 | 457 | if( !vlc_object_alive( p_playlist ) ) |
|---|
| 458 | 458 | { |
|---|
| 459 | | if( !b_locked ) PL_UNLOCK; |
|---|
| | 459 | PL_UNLOCK_IF( !b_locked ); |
|---|
| 460 | 460 | return VLC_EGENERIC; |
|---|
| 461 | 461 | } |
|---|
| … | … | |
| 492 | 492 | if( i_one ) *i_one = p_item_one->i_id; |
|---|
| 493 | 493 | |
|---|
| 494 | | if( !b_locked ) PL_UNLOCK; |
|---|
| | 494 | PL_UNLOCK_IF( !b_locked ); |
|---|
| 495 | 495 | return VLC_SUCCESS; |
|---|
| 496 | 496 | } |
|---|
| … | … | |
| 521 | 521 | if( p_playlist->b_die ) |
|---|
| 522 | 522 | return NULL; |
|---|
| 523 | | if( !b_locked ) PL_LOCK; |
|---|
| | 523 | PL_LOCK_IF( !b_locked ); |
|---|
| 524 | 524 | |
|---|
| 525 | 525 | p_item = playlist_ItemNewFromInput( p_playlist, p_input ); |
|---|
| … | … | |
| 527 | 527 | AddItem( p_playlist, p_item, p_parent, i_mode, i_pos ); |
|---|
| 528 | 528 | |
|---|
| 529 | | if( !b_locked ) PL_UNLOCK; |
|---|
| | 529 | PL_UNLOCK_IF( !b_locked ); |
|---|
| 530 | 530 | |
|---|
| 531 | 531 | return p_item; |
|---|
| … | … | |
| 567 | 567 | */ |
|---|
| 568 | 568 | |
|---|
| 569 | | if( !b_locked ) PL_LOCK; |
|---|
| | 569 | PL_LOCK_IF( !b_locked ); |
|---|
| 570 | 570 | |
|---|
| 571 | 571 | /* Fast track the media library, no time to loose */ |
|---|
| 572 | 572 | if( p_item == p_playlist->p_ml_category ) { |
|---|
| 573 | | if( !b_locked ) PL_UNLOCK; |
|---|
| | 573 | PL_UNLOCK_IF( !b_locked ); |
|---|
| 574 | 574 | return p_item; |
|---|
| 575 | 575 | } |
|---|
| … | … | |
| 604 | 604 | var_SetInteger( p_playlist, "item-change", p_item_in_category-> |
|---|
| 605 | 605 | p_input->i_id ); |
|---|
| 606 | | if( !b_locked ) PL_UNLOCK; |
|---|
| | 606 | PL_UNLOCK_IF( !b_locked ); |
|---|
| 607 | 607 | return p_item_in_category; |
|---|
| 608 | 608 | } |
|---|
| … | … | |
| 610 | 610 | { |
|---|
| 611 | 611 | ChangeToNode( p_playlist, p_item ); |
|---|
| 612 | | if( !b_locked ) PL_UNLOCK; |
|---|
| | 612 | PL_UNLOCK_IF( !b_locked ); |
|---|
| 613 | 613 | return NULL; |
|---|
| 614 | 614 | } |
|---|
| r7f717d6 |
race44bc |
|
| 144 | 144 | #define PLI_NAME( p ) p && p->p_input ? p->p_input->psz_name : "null" |
|---|
| 145 | 145 | |
|---|
| 146 | | #define PL_ASSERT_LOCKED vlc_assert_locked( &(vlc_internals(p_playlist)->lock) ); |
|---|
| | 146 | #define PL_ASSERT_LOCKED vlc_assert_locked( &(vlc_internals(p_playlist)->lock) ) |
|---|
| 147 | 147 | |
|---|
| | 148 | #define PL_LOCK_IF( cond ) pl_lock_if( p_playlist, cond ) |
|---|
| | 149 | static inline void pl_lock_if( playlist_t * p_playlist, bool cond ) |
|---|
| | 150 | { |
|---|
| | 151 | if( cond ) PL_LOCK; else PL_ASSERT_LOCKED; |
|---|
| | 152 | } |
|---|
| | 153 | |
|---|
| | 154 | #define PL_UNLOCK_IF( cond ) pl_unlock_if( p_playlist, cond ) |
|---|
| | 155 | static inline void pl_unlock_if( playlist_t * p_playlist, bool cond ) |
|---|
| | 156 | { |
|---|
| | 157 | if( cond ) PL_UNLOCK; |
|---|
| | 158 | } |
|---|
| 148 | 159 | |
|---|
| 149 | 160 | #endif /* !__LIBVLC_PLAYLIST_INTERNAL_H */ |
|---|
| r7f717d6 |
race44bc |
|
| 45 | 45 | { |
|---|
| 46 | 46 | int i; |
|---|
| 47 | | if( !b_locked ) PL_LOCK; |
|---|
| | 47 | PL_LOCK_IF( !b_locked ); |
|---|
| 48 | 48 | ARRAY_BSEARCH( p_playlist->all_items,->i_id, int, i_id, i ); |
|---|
| 49 | 49 | if( i != -1 ) |
|---|
| 50 | 50 | { |
|---|
| 51 | | if( !b_locked ) PL_UNLOCK; |
|---|
| | 51 | PL_UNLOCK_IF( !b_locked ); |
|---|
| 52 | 52 | return ARRAY_VAL( p_playlist->all_items, i ); |
|---|
| 53 | 53 | } |
|---|
| 54 | | if( !b_locked ) PL_UNLOCK; |
|---|
| | 54 | PL_UNLOCK_IF( !b_locked ); |
|---|
| 55 | 55 | return NULL; |
|---|
| 56 | 56 | } |
|---|
| … | … | |
| 68 | 68 | { |
|---|
| 69 | 69 | int i; |
|---|
| 70 | | if( !b_locked ) PL_LOCK; |
|---|
| | 70 | PL_LOCK_IF( !b_locked ); |
|---|
| 71 | 71 | if( get_current_status_item( p_playlist ) && |
|---|
| 72 | 72 | get_current_status_item( p_playlist )->p_input == p_item ) |
|---|
| 73 | 73 | { |
|---|
| 74 | | if( !b_locked ) PL_UNLOCK; |
|---|
| 75 | | return get_current_status_item( p_playlist ); |
|---|
| | 74 | /* FIXME: this is potentially dangerous, we could destroy |
|---|
| | 75 | * p_ret any time soon */ |
|---|
| | 76 | input_item_t *p_ret = get_current_status_item( p_playlist ); |
|---|
| | 77 | PL_UNLOCK_IF( !b_locked ); |
|---|
| | 78 | return p_ret; |
|---|
| 76 | 79 | } |
|---|
| 77 | 80 | /** \todo Check if this is always incremental and whether we can bsearch */ |
|---|
| … | … | |
| 80 | 83 | if( ARRAY_VAL(p_playlist->all_items, i)->p_input->i_id == p_item->i_id ) |
|---|
| 81 | 84 | { |
|---|
| 82 | | if( !b_locked ) PL_UNLOCK; |
|---|
| | 85 | PL_UNLOCK_IF( !b_locked ); |
|---|
| 83 | 86 | return ARRAY_VAL(p_playlist->all_items, i); |
|---|
| 84 | 87 | } |
|---|
| 85 | 88 | } |
|---|
| 86 | | if( !b_locked ) PL_UNLOCK; |
|---|
| | 89 | PL_UNLOCK_IF( !b_locked ); |
|---|
| 87 | 90 | return NULL; |
|---|
| 88 | 91 | } |
|---|