Changeset 6ecd4022a3d284f86f1ee632952aa81b8157d17f
- Timestamp:
- 16/09/06 00:10:37
(2 years ago)
- Author:
- Clément Stenac <zorglub@videolan.org>
- git-committer:
- Clément Stenac <zorglub@videolan.org> 1158358237 +0000
- git-parent:
[3f99651d8fa1356203faf67103e1c500d3b30e16]
- git-author:
- Clément Stenac <zorglub@videolan.org> 1158358237 +0000
- Message:
Remove vlc_object_find for playlist from the core
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r28d49d9 |
r6ecd402 |
|
| 25 | 25 | #define _VLC_PLAYLIST_H_ |
|---|
| 26 | 26 | |
|---|
| | 27 | #include <assert.h> |
|---|
| | 28 | |
|---|
| 27 | 29 | /** |
|---|
| 28 | 30 | * \file |
|---|
| … | … | |
| 208 | 210 | #define PL_LOCK vlc_mutex_lock( &p_playlist->object_lock ); |
|---|
| 209 | 211 | #define PL_UNLOCK vlc_mutex_unlock( &p_playlist->object_lock ); |
|---|
| | 212 | |
|---|
| | 213 | #define pl_Get( a ) a->p_libvlc->p_playlist |
|---|
| | 214 | #define pl_Yield( a ) __pl_Yield( VLC_OBJECT(a) ) |
|---|
| | 215 | static inline playlist_t *__pl_Yield( vlc_object_t *p_this ) |
|---|
| | 216 | { |
|---|
| | 217 | assert( p_this->p_libvlc->p_playlist ); |
|---|
| | 218 | vlc_object_yield( p_this->p_libvlc->p_playlist ); |
|---|
| | 219 | return p_this->p_libvlc->p_playlist; |
|---|
| | 220 | } |
|---|
| | 221 | #define pl_Release(a) vlc_object_release( a->p_libvlc->p_playlist ); |
|---|
| 210 | 222 | |
|---|
| 211 | 223 | /* Playlist control */ |
|---|
| r83f23b6 |
r6ecd402 |
|
| 531 | 531 | static void NotifyPlaylist( input_thread_t *p_input ) |
|---|
| 532 | 532 | { |
|---|
| 533 | | playlist_t *p_playlist = |
|---|
| 534 | | (playlist_t *)vlc_object_find( p_input, VLC_OBJECT_PLAYLIST, |
|---|
| 535 | | FIND_PARENT ); |
|---|
| 536 | | if( p_playlist ) |
|---|
| 537 | | { |
|---|
| 538 | | var_SetInteger( p_playlist, "item-change", |
|---|
| 539 | | p_input->input.p_item->i_id ); |
|---|
| 540 | | vlc_object_release( p_playlist ); |
|---|
| 541 | | } |
|---|
| | 533 | playlist_t *p_playlist = pl_Yield( p_input ); |
|---|
| | 534 | var_SetInteger( p_playlist, "item-change", |
|---|
| | 535 | p_input->input.p_item->i_id ); |
|---|
| | 536 | pl_Release( p_input ); |
|---|
| 542 | 537 | } |
|---|
| 543 | 538 | |
|---|
| r8923568 |
r6ecd402 |
|
| 1136 | 1136 | if( p_input->p_sout ) |
|---|
| 1137 | 1137 | { |
|---|
| 1138 | | vlc_object_t *p_pl = |
|---|
| 1139 | | vlc_object_find( p_input, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE ); |
|---|
| 1140 | 1138 | vlc_value_t keep; |
|---|
| 1141 | 1139 | |
|---|
| … | … | |
| 1146 | 1144 | vlc_mutex_unlock( &p_input->counters.counters_lock ); |
|---|
| 1147 | 1145 | |
|---|
| 1148 | | if( var_Get( p_input, "sout-keep", &keep ) >= 0 && keep.b_bool && p_pl ) |
|---|
| | 1146 | if( var_Get( p_input, "sout-keep", &keep ) >= 0 && keep.b_bool ) |
|---|
| 1149 | 1147 | { |
|---|
| 1150 | 1148 | /* attach sout to the playlist */ |
|---|
| 1151 | 1149 | msg_Dbg( p_input, "keeping sout" ); |
|---|
| 1152 | 1150 | vlc_object_detach( p_input->p_sout ); |
|---|
| 1153 | | vlc_object_attach( p_input->p_sout, p_pl ); |
|---|
| | 1151 | vlc_object_attach( p_input->p_sout, p_input->p_libvlc->p_playlist ); |
|---|
| 1154 | 1152 | } |
|---|
| 1155 | 1153 | else |
|---|
| … | … | |
| 1158 | 1156 | sout_DeleteInstance( p_input->p_sout ); |
|---|
| 1159 | 1157 | } |
|---|
| 1160 | | if( p_pl ) |
|---|
| 1161 | | vlc_object_release( p_pl ); |
|---|
| 1162 | 1158 | } |
|---|
| 1163 | 1159 | |
|---|
| … | … | |
| 1825 | 1821 | vlc_bool_t b_quick ) |
|---|
| 1826 | 1822 | { |
|---|
| 1827 | | playlist_t *p_playlist; |
|---|
| 1828 | 1823 | char psz_buffer[MSTRTIME_MAX_SIZE]; |
|---|
| 1829 | 1824 | |
|---|
| … | … | |
| 1832 | 1827 | vlc_mutex_unlock( &p_input->input.p_item->lock ); |
|---|
| 1833 | 1828 | |
|---|
| 1834 | | p_playlist = vlc_object_find( p_input, VLC_OBJECT_PLAYLIST, |
|---|
| 1835 | | FIND_PARENT); |
|---|
| 1836 | | if( p_playlist ) |
|---|
| 1837 | | { |
|---|
| 1838 | | var_SetInteger( p_playlist, "item-change", |
|---|
| 1839 | | p_input->input.p_item->i_id ); |
|---|
| 1840 | | vlc_object_release( p_playlist ); |
|---|
| 1841 | | } |
|---|
| | 1829 | pl_Yield( p_input ); |
|---|
| | 1830 | var_SetInteger( pl_Get( p_input ), "item-change", |
|---|
| | 1831 | p_input->input.p_item->i_id ); |
|---|
| | 1832 | pl_Release( p_input ) |
|---|
| 1842 | 1833 | |
|---|
| 1843 | 1834 | input_Control( p_input, INPUT_ADD_INFO, _("General"), _("Duration"), |
|---|
| r3f1e3ab |
r6ecd402 |
|
| 71 | 71 | { |
|---|
| 72 | 72 | vlc_object_t *p_obj = (vlc_object_t *)p_this->p_destructor_arg; |
|---|
| | 73 | input_item_t *p_input = (input_item_t *) p_this; |
|---|
| 73 | 74 | int i; |
|---|
| 74 | | input_item_t *p_input = (input_item_t *) p_this; |
|---|
| 75 | | |
|---|
| 76 | | playlist_t *p_playlist = (playlist_t *)vlc_object_find( p_obj, |
|---|
| 77 | | VLC_OBJECT_PLAYLIST, FIND_ANYWHERE ); |
|---|
| 78 | | |
|---|
| | 75 | |
|---|
| | 76 | playlist_t *p_playlist = pl_Yield( p_obj ); |
|---|
| 79 | 77 | vlc_input_item_Clean( p_input ); |
|---|
| 80 | 78 | |
|---|
| 81 | | if( p_playlist ) |
|---|
| 82 | | { |
|---|
| 83 | | for( i = 0 ; i< p_playlist->i_input_items ; i++ ) |
|---|
| 84 | | { |
|---|
| 85 | | if( p_playlist->pp_input_items[i]->i_id == p_input->i_id ) |
|---|
| 86 | | { |
|---|
| 87 | | REMOVE_ELEM( p_playlist->pp_input_items, |
|---|
| 88 | | p_playlist->i_input_items, i ); |
|---|
| 89 | | break; |
|---|
| 90 | | } |
|---|
| 91 | | } |
|---|
| 92 | | vlc_object_release( p_playlist ); |
|---|
| 93 | | } |
|---|
| | 79 | for( i = 0 ; i< p_playlist->i_input_items ; i++ ) |
|---|
| | 80 | { |
|---|
| | 81 | if( p_playlist->pp_input_items[i]->i_id == p_input->i_id ) |
|---|
| | 82 | { |
|---|
| | 83 | REMOVE_ELEM( p_playlist->pp_input_items, |
|---|
| | 84 | p_playlist->i_input_items, i ); |
|---|
| | 85 | break; |
|---|
| | 86 | } |
|---|
| | 87 | } |
|---|
| | 88 | pl_Release( p_obj ); |
|---|
| 94 | 89 | free( p_input ); |
|---|
| 95 | 90 | } |
|---|
| … | … | |
| 209 | 204 | int i_type ) |
|---|
| 210 | 205 | { |
|---|
| 211 | | /* FIXME DON'T SEARCH PLAYLIST */ |
|---|
| 212 | | /* FIXME SHOULD LOCK */ |
|---|
| 213 | | input_item_t *p_input = (input_item_t *)malloc( sizeof( input_item_t ) ); |
|---|
| 214 | | playlist_t *p_playlist = (playlist_t *) vlc_object_find( p_obj, |
|---|
| 215 | | VLC_OBJECT_PLAYLIST, FIND_ANYWHERE ); |
|---|
| | 206 | playlist_t *p_playlist = pl_Yield( p_obj ); |
|---|
| | 207 | DECMALLOC_NULL( p_input, input_item_t ); |
|---|
| 216 | 208 | |
|---|
| 217 | 209 | vlc_input_item_Init( p_obj, p_input ); |
|---|
| 218 | 210 | vlc_gc_init( p_input, vlc_input_item_Destroy, (void *)p_obj ); |
|---|
| 219 | 211 | |
|---|
| | 212 | PL_LOCK; |
|---|
| 220 | 213 | p_input->i_id = ++p_playlist->i_last_input_id; |
|---|
| 221 | | |
|---|
| 222 | | INSERT_ELEM( p_playlist->pp_input_items, p_playlist->i_input_items, |
|---|
| 223 | | p_playlist->i_input_items, p_input ); |
|---|
| 224 | | vlc_object_release( p_playlist ); |
|---|
| | 214 | TAB_APPEND( p_playlist->i_input_items, |
|---|
| | 215 | p_playlist->pp_input_items, |
|---|
| | 216 | p_input ); |
|---|
| | 217 | PL_UNLOCK; |
|---|
| | 218 | pl_Release( p_obj ); |
|---|
| 225 | 219 | |
|---|
| 226 | 220 | p_input->b_fixed_name = VLC_FALSE; |
|---|
| r928454f |
r6ecd402 |
|
| 446 | 446 | static interaction_t * InteractionGet( vlc_object_t *p_this ) |
|---|
| 447 | 447 | { |
|---|
| 448 | | playlist_t *p_playlist; |
|---|
| 449 | 448 | interaction_t *p_interaction; |
|---|
| 450 | | |
|---|
| 451 | | p_playlist = (playlist_t*) vlc_object_find( p_this, VLC_OBJECT_PLAYLIST, |
|---|
| 452 | | FIND_ANYWHERE ); |
|---|
| 453 | | if( !p_playlist ) |
|---|
| 454 | | return NULL; |
|---|
| 455 | | |
|---|
| | 449 | playlist_t *p_playlist = pl_Yield( p_this ); |
|---|
| | 450 | |
|---|
| | 451 | PL_LOCK; |
|---|
| 456 | 452 | if( p_playlist->p_interaction == NULL ) |
|---|
| 457 | 453 | InteractionInit( p_playlist ); |
|---|
| 458 | 454 | |
|---|
| 459 | 455 | p_interaction = p_playlist->p_interaction; |
|---|
| 460 | | |
|---|
| 461 | | vlc_object_release( p_playlist ); |
|---|
| | 456 | PL_UNLOCK; |
|---|
| | 457 | |
|---|
| | 458 | pl_Release( p_this ); |
|---|
| 462 | 459 | return p_interaction; |
|---|
| 463 | 460 | } |
|---|
| r83f23b6 |
r6ecd402 |
|
| 115 | 115 | if( !p_fmt ) |
|---|
| 116 | 116 | { |
|---|
| 117 | | /* Reattach video output to input before bailing out */ |
|---|
| | 117 | /* Reattach video output to playlist before bailing out */ |
|---|
| 118 | 118 | if( p_vout ) |
|---|
| 119 | 119 | { |
|---|
| 120 | | vlc_object_t *p_playlist; |
|---|
| 121 | | |
|---|
| 122 | | p_playlist = vlc_object_find( p_this, VLC_OBJECT_PLAYLIST, |
|---|
| 123 | | FIND_ANYWHERE ); |
|---|
| 124 | | |
|---|
| 125 | | if( p_playlist ) |
|---|
| 126 | | { |
|---|
| 127 | | spu_Attach( p_vout->p_spu, p_this, VLC_FALSE ); |
|---|
| 128 | | vlc_object_detach( p_vout ); |
|---|
| 129 | | vlc_object_attach( p_vout, p_playlist ); |
|---|
| 130 | | |
|---|
| 131 | | vlc_object_release( p_playlist ); |
|---|
| 132 | | } |
|---|
| 133 | | else |
|---|
| 134 | | { |
|---|
| 135 | | msg_Dbg( p_this, "cannot find playlist, destroying vout" ); |
|---|
| 136 | | vlc_object_detach( p_vout ); |
|---|
| 137 | | vout_Destroy( p_vout ); |
|---|
| 138 | | } |
|---|
| | 120 | vlc_object_t *p_playlist = pl_Yield( p_this ); |
|---|
| | 121 | spu_Attach( p_vout->p_spu, p_this, VLC_FALSE ); |
|---|
| | 122 | vlc_object_detach( p_vout ); |
|---|
| | 123 | vlc_object_attach( p_vout, p_playlist ); |
|---|
| | 124 | pl_Release( p_this ); |
|---|
| 139 | 125 | } |
|---|
| 140 | 126 | return NULL; |
|---|
| … | … | |
| 152 | 138 | if( !p_vout ) |
|---|
| 153 | 139 | { |
|---|
| 154 | | playlist_t *p_playlist; |
|---|
| 155 | | |
|---|
| 156 | | p_playlist = vlc_object_find( p_this, |
|---|
| 157 | | VLC_OBJECT_PLAYLIST, FIND_ANYWHERE ); |
|---|
| 158 | | if( p_playlist ) |
|---|
| 159 | | { |
|---|
| 160 | | vlc_mutex_lock( &p_playlist->gc_lock ); |
|---|
| 161 | | p_vout = vlc_object_find( p_playlist, |
|---|
| 162 | | VLC_OBJECT_VOUT, FIND_CHILD ); |
|---|
| 163 | | /* only first children of p_input for unused vout */ |
|---|
| 164 | | if( p_vout && p_vout->p_parent != (vlc_object_t *)p_playlist ) |
|---|
| 165 | | { |
|---|
| 166 | | vlc_object_release( p_vout ); |
|---|
| 167 | | p_vout = NULL; |
|---|
| 168 | | } |
|---|
| 169 | | vlc_mutex_unlock( &p_playlist->gc_lock ); |
|---|
| 170 | | vlc_object_release( p_playlist ); |
|---|
| 171 | | } |
|---|
| | 140 | playlist_t *p_playlist = pl_Yield( p_this ); |
|---|
| | 141 | vlc_mutex_lock( &p_playlist->gc_lock ); |
|---|
| | 142 | p_vout = vlc_object_find( p_playlist, |
|---|
| | 143 | VLC_OBJECT_VOUT, FIND_CHILD ); |
|---|
| | 144 | /* only first children of p_input for unused vout */ |
|---|
| | 145 | if( p_vout && p_vout->p_parent != (vlc_object_t *)p_playlist ) |
|---|
| | 146 | { |
|---|
| | 147 | vlc_object_release( p_vout ); |
|---|
| | 148 | p_vout = NULL; |
|---|
| | 149 | } |
|---|
| | 150 | vlc_mutex_unlock( &p_playlist->gc_lock ); |
|---|
| 172 | 151 | } |
|---|
| 173 | 152 | } |
|---|
| … | … | |
| 499 | 478 | void vout_Destroy( vout_thread_t *p_vout ) |
|---|
| 500 | 479 | { |
|---|
| 501 | | vlc_object_t *p_playlist; |
|---|
| | 480 | vout_thread_t *p_another_vout; |
|---|
| | 481 | vlc_object_t *p_playlist = pl_Yield( p_vout ); |
|---|
| 502 | 482 | |
|---|
| 503 | 483 | /* Request thread destruction */ |
|---|
| … | … | |
| 507 | 487 | var_Destroy( p_vout, "intf-change" ); |
|---|
| 508 | 488 | |
|---|
| 509 | | p_playlist = vlc_object_find( p_vout, VLC_OBJECT_PLAYLIST, |
|---|
| 510 | | FIND_ANYWHERE ); |
|---|
| 511 | | |
|---|
| 512 | 489 | if( p_vout->psz_filter_chain ) free( p_vout->psz_filter_chain ); |
|---|
| 513 | 490 | |
|---|
| … | … | |
| 515 | 492 | vlc_object_destroy( p_vout ); |
|---|
| 516 | 493 | |
|---|
| 517 | | /* If it was the last vout, tell the interface to show up */ |
|---|
| 518 | | if( p_playlist != NULL ) |
|---|
| 519 | | { |
|---|
| 520 | | vout_thread_t *p_another_vout = vlc_object_find( p_playlist, |
|---|
| 521 | | VLC_OBJECT_VOUT, FIND_ANYWHERE ); |
|---|
| 522 | | if( p_another_vout == NULL ) |
|---|
| 523 | | { |
|---|
| 524 | | vlc_value_t val; |
|---|
| 525 | | val.b_bool = VLC_TRUE; |
|---|
| 526 | | var_Set( p_playlist, "intf-show", val ); |
|---|
| 527 | | } |
|---|
| 528 | | else |
|---|
| 529 | | { |
|---|
| 530 | | vlc_object_release( p_another_vout ); |
|---|
| 531 | | } |
|---|
| 532 | | vlc_object_release( p_playlist ); |
|---|
| 533 | | } |
|---|
| | 494 | p_another_vout = vlc_object_find( p_playlist, |
|---|
| | 495 | VLC_OBJECT_VOUT, FIND_ANYWHERE ); |
|---|
| | 496 | if( p_another_vout == NULL ) |
|---|
| | 497 | { |
|---|
| | 498 | vlc_value_t val; |
|---|
| | 499 | val.b_bool = VLC_TRUE; |
|---|
| | 500 | var_Set( p_playlist, "intf-show", val ); |
|---|
| | 501 | } |
|---|
| | 502 | else |
|---|
| | 503 | { |
|---|
| | 504 | vlc_object_release( p_another_vout ); |
|---|
| | 505 | } |
|---|
| | 506 | vlc_object_release( p_playlist ); |
|---|
| 534 | 507 | } |
|---|
| 535 | 508 | |
|---|
| rf485214 |
r6ecd402 |
|
| 1100 | 1100 | { |
|---|
| 1101 | 1101 | vout_thread_t *p_vout = (vout_thread_t *)p_this; |
|---|
| 1102 | | playlist_t *p_playlist; |
|---|
| | 1102 | playlist_t *p_playlist = pl_Yield( p_this ); |
|---|
| 1103 | 1103 | vout_Control( p_vout, VOUT_SET_STAY_ON_TOP, newval.b_bool ); |
|---|
| 1104 | 1104 | |
|---|
| 1105 | | p_playlist = (playlist_t *)vlc_object_find( p_this, VLC_OBJECT_PLAYLIST, |
|---|
| 1106 | | FIND_PARENT ); |
|---|
| 1107 | | if( p_playlist ) |
|---|
| 1108 | | { |
|---|
| 1109 | | /* Modify playlist as well because the vout might have to be restarted */ |
|---|
| 1110 | | var_Create( p_playlist, "video-on-top", VLC_VAR_BOOL ); |
|---|
| 1111 | | var_Set( p_playlist, "video-on-top", newval ); |
|---|
| 1112 | | |
|---|
| 1113 | | vlc_object_release( p_playlist ); |
|---|
| 1114 | | } |
|---|
| | 1105 | /* Modify playlist as well because the vout might have to be restarted */ |
|---|
| | 1106 | var_Create( p_playlist, "video-on-top", VLC_VAR_BOOL ); |
|---|
| | 1107 | var_Set( p_playlist, "video-on-top", newval ); |
|---|
| | 1108 | |
|---|
| | 1109 | pl_Release( p_this ); |
|---|
| 1115 | 1110 | return VLC_SUCCESS; |
|---|
| 1116 | 1111 | } |
|---|
| … | … | |
| 1120 | 1115 | { |
|---|
| 1121 | 1116 | vout_thread_t *p_vout = (vout_thread_t *)p_this; |
|---|
| 1122 | | playlist_t *p_playlist; |
|---|
| 1123 | 1117 | vlc_value_t val; |
|---|
| | 1118 | playlist_t *p_playlist = pl_Yield( p_this ); |
|---|
| 1124 | 1119 | |
|---|
| 1125 | 1120 | p_vout->i_changes |= VOUT_FULLSCREEN_CHANGE; |
|---|
| 1126 | 1121 | |
|---|
| 1127 | | p_playlist = (playlist_t *)vlc_object_find( p_this, VLC_OBJECT_PLAYLIST, |
|---|
| 1128 | | FIND_PARENT ); |
|---|
| 1129 | | if( p_playlist ) |
|---|
| 1130 | | { |
|---|
| 1131 | | /* Modify playlist as well because the vout might have to be restarted */ |
|---|
| 1132 | | var_Create( p_playlist, "fullscreen", VLC_VAR_BOOL ); |
|---|
| 1133 | | var_Set( p_playlist, "fullscreen", newval ); |
|---|
| 1134 | | |
|---|
| 1135 | | vlc_object_release( p_playlist ); |
|---|
| 1136 | | } |
|---|
| | 1122 | /* Modify playlist as well because the vout might have to be restarted */ |
|---|
| | 1123 | var_Create( p_playlist, "fullscreen", VLC_VAR_BOOL ); |
|---|
| | 1124 | var_Set( p_playlist, "fullscreen", newval ); |
|---|
| | 1125 | pl_Release( p_playlist ); |
|---|
| 1137 | 1126 | |
|---|
| 1138 | 1127 | /* Disable "always on top" in fullscreen mode */ |
|---|