Changeset 2d3be24e0f67e19dc29baced87af42481dafde21
- Timestamp:
- 21/10/06 15:33:06 (2 years ago)
- git-parent:
- Files:
-
- include/vlc_playlist.h (modified) (2 diffs)
- modules/gui/qt4/dialogs/interaction.cpp (modified) (1 diff)
- src/input/input.c (modified) (3 diffs)
- src/interface/interaction.c (modified) (5 diffs)
- src/playlist/control.c (modified) (1 diff)
- src/playlist/engine.c (modified) (9 diffs)
- src/playlist/item.c (modified) (2 diffs)
- src/playlist/thread.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
include/vlc_playlist.h
r799b282 r2d3be24 138 138 int i_sort; /**< Last sorting applied to the playlist */ 139 139 int i_order; /**< Last ordering applied to the playlist */ 140 mtime_t i_vout_destroyed_date;141 mtime_t i_sout_destroyed_date;140 mtime_t gc_date; 141 vlc_bool_t b_cant_sleep; 142 142 playlist_preparse_t *p_preparse; /**< Preparser object */ 143 143 playlist_secondary_preparse_t *p_secondary_preparse;/**< Preparser object */ … … 434 434 } 435 435 436 /** Ask the playlist to do some work */ 437 static inline void playlist_Signal( playlist_t *p_playlist ) 438 { 439 PL_LOCK; 440 vlc_cond_signal( &p_playlist->object_wait ); 441 PL_UNLOCK; 442 } 443 436 444 /** 437 445 * @} modules/gui/qt4/dialogs/interaction.cpp
r928454f r2d3be24 196 196 hide(); 197 197 vlc_mutex_unlock( &p_dialog->p_interaction->object_lock ); 198 playlist_Signal( THEPL ); 198 199 } src/input/input.c
r6b5014a r2d3be24 381 381 p_input->b_die = VLC_TRUE; 382 382 383 /* We cannot touch p_input fields directly (we c anfrom another thread),383 /* We cannot touch p_input fields directly (we come from another thread), 384 384 * so use the vlc_object_find way, it's perfectly safe */ 385 385 … … 443 443 /* If we failed, wait before we are killed, and exit */ 444 444 p_input->b_error = VLC_TRUE; 445 playlist_Signal( pl_Get( p_input ) ); 445 446 446 447 Error( p_input ); … … 469 470 /* We have finished */ 470 471 p_input->b_eof = VLC_TRUE; 472 playlist_Signal( pl_Get( p_input ) ); 471 473 } 472 474 src/interface/interaction.c
ra972b8b r2d3be24 103 103 // Pretend we have hidden and destroyed it 104 104 if( p_dialog->i_status == HIDDEN_DIALOG ) 105 {106 105 p_dialog->i_status = DESTROYED_DIALOG; 107 }108 106 else 109 {110 107 p_dialog->i_status = HIDING_DIALOG; 111 }112 108 } 113 109 } 114 110 else 115 {116 111 vlc_object_yield( p_interaction->p_intf ); 117 }118 112 119 113 for( i_index = 0 ; i_index < p_interaction->i_dialogs; i_index ++ ) … … 526 520 static void DialogDestroy( interaction_dialog_t *p_dialog ) 527 521 { 528 FREENULL( p_dialog->psz_title );529 FREENULL( p_dialog->psz_description );530 FREENULL( p_dialog->psz_default_button );531 FREENULL( p_dialog->psz_alternate_button );532 FREENULL( p_dialog->psz_other_button );522 free( p_dialog->psz_title ); 523 free( p_dialog->psz_description ); 524 free( p_dialog->psz_default_button ); 525 free( p_dialog->psz_alternate_button ); 526 free( p_dialog->psz_other_button ); 533 527 free( p_dialog ); 534 528 } … … 576 570 if( p_dialog->i_type == INTERACT_DIALOG_TWOWAY ) // Wait for answer 577 571 { 572 playlist_Signal( pl_Get(p_this) ); 578 573 while( p_dialog->i_status != ANSWERED_DIALOG && 579 574 p_dialog->i_status != HIDING_DIALOG && … … 592 587 p_dialog->i_flags |= DIALOG_GOT_ANSWER; 593 588 vlc_mutex_unlock( &p_interaction->object_lock ); 589 playlist_Signal( pl_Get(p_this) ); 594 590 return p_dialog->i_return; 595 591 } … … 599 595 p_dialog->i_flags |= DIALOG_GOT_ANSWER; 600 596 vlc_mutex_unlock( &p_interaction->object_lock ); 597 playlist_Signal( pl_Get(p_this) ); 601 598 return VLC_SUCCESS; 602 599 } src/playlist/control.c
r799b282 r2d3be24 180 180 break; 181 181 } 182 vlc_cond_signal( &p_playlist->object_wait ); 182 183 183 184 return VLC_SUCCESS; src/playlist/engine.c
r799b282 r2d3be24 71 71 p_playlist->p_input = NULL; 72 72 73 p_playlist-> i_vout_destroyed_date = 0;74 p_playlist-> i_sout_destroyed_date = 0;73 p_playlist->gc_date = 0; 74 p_playlist->b_cant_sleep = VLC_FALSE; 75 75 76 76 ARRAY_INIT( p_playlist->items ); … … 195 195 196 196 } 197 197 198 /* Destroy remaining objects */ 198 static mtime_t ObjectGarbageCollector( playlist_t *p_playlist, int i_type, 199 mtime_t destroy_date ) 199 static void ObjectGarbageCollector( playlist_t *p_playlist ) 200 200 { 201 201 vlc_object_t *p_obj; 202 202 203 if( destroy_date > mdate() ) return destroy_date; 204 205 if( destroy_date == 0 ) 206 { 207 /* give a little time */ 208 return mdate() + I64C(1000000); 209 } 210 else 211 { 212 vlc_mutex_lock( &p_playlist->gc_lock ); 213 while( ( p_obj = vlc_object_find( p_playlist, i_type, FIND_CHILD ) ) ) 214 { 215 if( p_obj->p_parent != (vlc_object_t*)p_playlist ) 216 { 217 /* only first child (ie unused) */ 218 vlc_object_release( p_obj ); 219 break; 220 } 221 if( i_type == VLC_OBJECT_VOUT ) 222 { 223 msg_Dbg( p_playlist, "garbage collector destroying 1 vout" ); 224 vlc_object_detach( p_obj ); 225 vlc_object_release( p_obj ); 226 vout_Destroy( (vout_thread_t *)p_obj ); 227 } 228 else if( i_type == VLC_OBJECT_SOUT ) 229 { 230 vlc_object_release( p_obj ); 231 sout_DeleteInstance( (sout_instance_t*)p_obj ); 232 } 233 } 234 vlc_mutex_unlock( &p_playlist->gc_lock ); 235 return 0; 236 } 203 if( mdate() - p_playlist->gc_date < 1000000 ) 204 { 205 p_playlist->b_cant_sleep = VLC_TRUE; 206 return; 207 } 208 else if( p_playlist->gc_date == 0 ) 209 return; 210 211 vlc_mutex_lock( &p_playlist->gc_lock ); 212 while( ( p_obj = vlc_object_find( p_playlist, VLC_OBJECT_VOUT, 213 FIND_CHILD ) ) ) 214 { 215 if( p_obj->p_parent != (vlc_object_t*)p_playlist ) 216 { 217 vlc_object_release( p_obj ); 218 break; 219 } 220 msg_Dbg( p_playlist, "garbage collector destroying 1 vout" ); 221 vlc_object_detach( p_obj ); 222 vlc_object_release( p_obj ); 223 vout_Destroy( (vout_thread_t *)p_obj ); 224 } 225 while( ( p_obj = vlc_object_find( p_playlist, VLC_OBJECT_SOUT, 226 FIND_CHILD ) ) ) 227 { 228 if( p_obj->p_parent != (vlc_object_t*)p_playlist ) 229 { 230 vlc_object_release( p_obj ); 231 break; 232 } 233 vlc_object_release( p_obj ); 234 sout_DeleteInstance( (sout_instance_t*)p_obj ); 235 } 236 p_playlist->b_cant_sleep = VLC_FALSE; 237 vlc_mutex_unlock( &p_playlist->gc_lock ); 237 238 } 238 239 … … 245 246 246 247 /* First, check if we have something to do */ 247 /* FIXME : this can be called several times */248 248 if( p_playlist->request.b_request ) 249 249 { … … 255 255 } 256 256 } 257 257 check_input: 258 258 /* If there is an input, check that it doesn't need to die. */ 259 259 if( p_playlist->p_input ) … … 283 283 vlc_object_destroy( p_input ); 284 284 285 p_playlist->i_vout_destroyed_date = 0; 286 p_playlist->i_sout_destroyed_date = 0; 285 PL_LOCK; 286 287 p_playlist->gc_date = mdate(); 288 p_playlist->b_cant_sleep = VLC_TRUE; 287 289 288 290 if( p_playlist->status.p_item->i_flags … … 300 302 var_SetInteger( p_playlist, "activity", i_activity - 301 303 DEFAULT_INPUT_ACTIVITY ); 302 303 return; 304 goto check_input; 304 305 } 305 306 /* This input is dying, let it do */ … … 307 308 { 308 309 PL_DEBUG( "dying input" ); 310 msleep( 25000 ); // 25 ms 311 goto check_input; 309 312 } 310 313 /* This input has finished, ask it to die ! */ … … 314 317 PL_DEBUG( "finished input" ); 315 318 input_StopThread( p_playlist->p_input ); 316 /* Select the next playlist item */ 317 PL_UNLOCK 318 return; 319 /* No need to wait here, we'll wait in the p_input->b_die case */ 320 goto check_input; 319 321 } 320 322 else if( p_playlist->p_input->i_state != INIT_S ) 321 323 { 322 324 PL_UNLOCK; 323 p_playlist->i_vout_destroyed_date = 324 ObjectGarbageCollector( p_playlist, VLC_OBJECT_VOUT, 325 p_playlist->i_vout_destroyed_date ); 326 p_playlist->i_sout_destroyed_date = 327 ObjectGarbageCollector( p_playlist, VLC_OBJECT_SOUT, 328 p_playlist->i_sout_destroyed_date ); 329 PL_LOCK 325 ObjectGarbageCollector( p_playlist ); 326 PL_LOCK; 330 327 } 331 328 } … … 365 362 else 366 363 { 367 p_playlist->status.i_status = PLAYLIST_STOPPED; 368 if( p_playlist->status.p_item && 369 p_playlist->status.p_item->i_flags & PLAYLIST_REMOVE_FLAG ) 370 { 371 PL_DEBUG( "deleting item marked for deletion" ); 372 playlist_ItemDelete( p_playlist->status.p_item ); 373 p_playlist->status.p_item = NULL; 374 } 375 376 /* Collect garbage */ 377 PL_UNLOCK 378 p_playlist->i_sout_destroyed_date = 379 ObjectGarbageCollector( p_playlist, VLC_OBJECT_SOUT, mdate() ); 380 p_playlist->i_vout_destroyed_date = 381 ObjectGarbageCollector( p_playlist, VLC_OBJECT_VOUT, mdate() ); 382 PL_LOCK 383 } 364 p_playlist->status.i_status = PLAYLIST_STOPPED; 365 if( p_playlist->status.p_item && 366 p_playlist->status.p_item->i_flags & PLAYLIST_REMOVE_FLAG ) 367 { 368 PL_DEBUG( "deleting item marked for deletion" ); 369 playlist_ItemDelete( p_playlist->status.p_item ); 370 p_playlist->status.p_item = NULL; 371 } 372 373 /* Collect garbage */ 374 PL_UNLOCK; 375 ObjectGarbageCollector( p_playlist ); 376 PL_LOCK; 377 } 384 378 } 385 379 PL_UNLOCK src/playlist/item.c
r799b282 r2d3be24 595 595 p_playlist->request.p_item = p_toplay; 596 596 if( p_playlist->p_input ) 597 {598 597 input_StopThread( p_playlist->p_input ); 599 }600 598 p_playlist->request.i_status = PLAYLIST_RUNNING; 599 vlc_cond_signal( &p_playlist->object_wait ); 601 600 } 602 601 if( i_mode & PLAYLIST_PREPARSE && … … 667 666 p_playlist->request.p_item = NULL; 668 667 msg_Info( p_playlist, "stopping playback" ); 668 vlc_cond_signal( &p_playlist->object_wait ); 669 669 } 670 670 b_flag = VLC_TRUE; src/playlist/thread.c
r799b282 r2d3be24 143 143 { 144 144 p_playlist->b_die = VLC_TRUE; 145 playlist_Signal( p_playlist ); 145 146 if( p_playlist->p_preparse ) 146 147 { … … 176 177 HandleInteraction( p_playlist ); 177 178 HandlePlaylist( p_playlist ); 178 179 /* 100 ms is an acceptable delay for playlist operations */ 180 msleep( INTF_IDLE_SLEEP*2 ); 179 if( p_playlist->b_cant_sleep ) 180 { 181 /* 100 ms is an acceptable delay for playlist operations */ 182 msleep( INTF_IDLE_SLEEP*2 ); 183 } 184 else 185 { 186 PL_LOCK; 187 vlc_cond_wait( &p_playlist->object_wait, &p_playlist->object_lock ); 188 PL_UNLOCK; 189 } 181 190 } 182 191
