Changeset 799b2826ee321796c8c4695c5a7b7489ed5da851
- Timestamp:
- 10/21/06 13:09:51 (2 years ago)
- git-parent:
- Files:
-
- include/vlc_arrays.h (modified) (3 diffs)
- include/vlc_playlist.h (modified) (4 diffs)
- modules/control/hotkeys.c (modified) (1 diff)
- modules/control/http/macro.c (modified) (3 diffs)
- modules/gui/macosx/controls.m (modified) (2 diffs)
- modules/gui/macosx/intf.m (modified) (1 diff)
- modules/gui/macosx/playlist.m (modified) (2 diffs)
- modules/gui/qt4/main_interface.cpp (modified) (1 diff)
- modules/gui/qt4/menus.cpp (modified) (1 diff)
- modules/gui/skins2/commands/cmd_input.cpp (modified) (1 diff)
- src/control/mediacontrol_core.c (modified) (3 diffs)
- src/control/playlist.c (modified) (2 diffs)
- src/input/item.c (modified) (3 diffs)
- src/libvlc.c (modified) (1 diff)
- src/playlist/control.c (modified) (10 diffs)
- src/playlist/engine.c (modified) (4 diffs)
- src/playlist/item.c (modified) (6 diffs)
- src/playlist/search.c (modified) (3 diffs)
- src/playlist/thread.c (modified) (1 diff)
- src/playlist/tree.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
include/vlc_arrays.h
r266fb28 r799b282 119 119 120 120 /** 121 * Binary search in a n array121 * Binary search in a sorted array. The key must be comparable by < and > 122 122 * \param entries array of entries 123 123 * \param count number of entries … … 219 219 array.p_elems = NULL; 220 220 221 #define ARRAY_RESET(array) \ 222 array.i_alloc = 0; \ 223 array.i_size = 0; \ 224 free( array.p_elems ); array.p_elems = NULL; 225 221 226 #define ARRAY_APPEND(array, elem) { \ 222 227 _ARRAY_GROW1(array); \ … … 245 250 } 246 251 252 #define ARRAY_VAL(array, pos) array.p_elems[pos] 253 254 #define ARRAY_BSEARCH(array, elem, zetype, key, answer) \ 255 BSEARCH( array.p_elems, array.i_size, elem, zetype, key, answer) 256 257 #define FOREACH_ARRAY( item, array ) { \ 258 int fe_idx; \ 259 for( fe_idx = 0 ; fe_idx < array.i_size ; fe_idx++ ) \ 260 { \ 261 item = array.p_elems[fe_idx]; 262 263 #define FOREACH_END() } } 264 247 265 #endif include/vlc_playlist.h
r9cd8ee7 r799b282 27 27 #include <assert.h> 28 28 29 /** 30 * \file 31 * This file contain structures and function prototypes related 32 * to the playlist in vlc33 * /34 35 /**29 TYPEDEF_ARRAY(playlist_item_t*, playlist_item_array_t); 30 TYPEDEF_ARRAY(input_item_t*, input_item_array_t); 31 /** 32 * \file 33 * This file contain structures and function prototypes related 34 * to the playlist in vlc 35 * 36 36 * \defgroup vlc_playlist Playlist 37 37 * @{ … … 103 103 int i_enabled; /**< How many items are enabled ? */ 104 104 105 /* Arrays of items */ 106 int i_size; /**< total size of the list */ 107 playlist_item_t ** pp_items; /**< array of pointers to the 108 * playlist items */ 109 int i_all_size; /**< size of list of items and nodes */ 110 playlist_item_t ** pp_all_items; /**< array of pointers to the 111 * playlist items and nodes */ 112 int i_input_items; 113 input_item_t ** pp_input_items; 114 115 int i_random; /**< Number of candidates for random */ 116 playlist_item_t ** pp_random; /**< Random candidate items */ 117 int i_random_index; /**< Current random item */ 118 vlc_bool_t b_reset_random; /**< Recreate random array ?*/ 105 playlist_item_array_t items; /**< Arrays of items */ 106 playlist_item_array_t all_items; /**< Array of items and nodes */ 107 108 input_item_array_t input_items; /**< Array of input items */ 109 110 playlist_item_array_t current; /**< Items currently being played */ 111 int i_current_index; /**< Index in current array */ 112 /** Reset current item ? */ 113 vlc_bool_t b_reset_currently_playing; 119 114 120 115 int i_last_playlist_id; /**< Last id to an item */ … … 346 341 } 347 342 348 /** Add an input item to the playlist node 343 /** Add an input item to the playlist node 349 344 * \see playlist_AddInput 350 345 */ … … 434 429 vlc_bool_t b_empty; 435 430 vlc_mutex_lock( &p_playlist->object_lock ); 436 b_empty = p_playlist->i _size == 0;431 b_empty = p_playlist->items.i_size == 0; 437 432 vlc_mutex_unlock( &p_playlist->object_lock ); 438 433 return( b_empty ); modules/control/hotkeys.c
r353ece4 r799b282 797 797 798 798 char *psz_bookmark = strdup( val.psz_string ); 799 for( i = 0; i < p_playlist->i _size; i++)799 for( i = 0; i < p_playlist->items.i_size; i++) 800 800 { 801 801 if( !strcmp( psz_bookmark, 802 p_playlist->pp_items[i]->p_input->psz_uri ) )802 ARRAY_VAL( p_playlist->items,i )->p_input->psz_uri ) ) 803 803 { 804 804 playlist_LockControl( p_playlist, PLAYLIST_VIEWPLAY, NULL, 805 p_playlist->pp_items[i]);805 ARRAY_VAL( p_playlist->items, i ) ); 806 806 break; 807 807 } modules/control/http/macro.c
r4963328 r799b282 399 399 } 400 400 401 for( i = p_sys->p_playlist->i _size - 1 ; i >= 0; i-- )401 for( i = p_sys->p_playlist->items.i_size - 1 ; i >= 0; i-- ) 402 402 { 403 403 /* Check if the item is in the keep list */ … … 405 405 { 406 406 if( p_items[j] == 407 p_sys->p_playlist->pp_items[i]->p_input->i_id ) 407 ARRAY_VAL(p_sys->p_playlist->items,i) 408 ->p_input->i_id) 408 409 break; 409 410 } … … 411 412 { 412 413 playlist_LockDeleteAllFromInput( p_sys->p_playlist, 413 p_sys->p_playlist->pp_items[i]->p_input->i_id );414 p_sys->p_playlist->items.p_elems[i]->p_input->i_id ); 414 415 msg_Dbg( p_intf, "requested playlist delete: %d", 415 416 i ); modules/gui/macosx/controls.m
rd016a42 r799b282 69 69 70 70 vlc_mutex_lock( &p_playlist->object_lock ); 71 if( p _playlist->i_size <= 0)71 if( playlist_IsEmpty( p_playlist ) ) 72 72 { 73 73 vlc_mutex_unlock( &p_playlist->object_lock ); … … 813 813 [[o_mi title] isEqualToString: _NS("Next")] ) 814 814 { 815 bEnabled = p_playlist->i_size > 1; 815 /** \todo fix i_size use */ 816 bEnabled = p_playlist->items.i_size > 1; 816 817 } 817 818 else if( [[o_mi title] isEqualToString: _NS("Random")] ) modules/gui/macosx/intf.m
r9d7bec3 r799b282 1068 1068 1069 1069 playlist_t * p_playlist = pl_Yield( p_intf ); 1070 b_plmul = p_playlist->i_size > 1; 1070 /** \todo fix i_size use */ 1071 b_plmul = p_playlist->items.i_size > 1; 1071 1072 1072 1073 vlc_object_release( p_playlist ); modules/gui/macosx/playlist.m
r1194766 r799b282 465 465 playlist_t *p_playlist = pl_Yield( VLCIntf ); 466 466 467 if( p_playlist->i_size >= 2 ) 467 /** \todo fix i_size use */ 468 if( p_playlist->items.i_size >= 2 ) 468 469 { 469 470 [o_status_field setStringValue: [NSString stringWithFormat: 470 _NS("%i items in the playlist"), p_playlist->i _size]];471 _NS("%i items in the playlist"), p_playlist->items.i_size]]; 471 472 } 472 473 else 473 474 { 474 if( p _playlist->i_size == 0)475 if( playlist_IsEmpty( p_playlist ) ) 475 476 { 476 477 [o_status_field setStringValue: _NS("No items in the playlist")]; … … 1367 1368 /* FIXME: playlist->i_size doesn't provide the correct number of items anymore 1368 1369 * check the playlist API for the fixed function, once zorglub implemented it -- fpk, 9/17/06 */ 1369 1370 if( p_playlist->i _size >= 2 )1370 /** \todo fix i_size use */ 1371 if( p_playlist->items.i_size >= 2 ) 1371 1372 { 1372 1373 [o_status_field setStringValue: [NSString stringWithFormat: 1373 _NS("%i items in the playlist"), p_playlist->i _size]];1374 _NS("%i items in the playlist"), p_playlist->items.i_size]]; 1374 1375 } 1375 1376 else 1376 1377 { 1377 if( p _playlist->i_size == 0)1378 if( playlist_IsEmpty( p_playlist ) ) 1378 1379 { 1379 1380 [o_status_field setStringValue: _NS("No items in the playlist")]; modules/gui/qt4/main_interface.cpp
rac471f2 r799b282 557 557 void MainInterface::play() 558 558 { 559 if( ! THEPL->i_size|| !THEPL->i_enabled )559 if( !playlist_IsEmpty(THEPL) || !THEPL->i_enabled ) 560 560 { 561 561 /* The playlist is empty, open a file requester */ modules/gui/qt4/menus.cpp
r141dd1d r799b282 355 355 MIM_SADD( qtr("Pause"), "", "", togglePlayPause() ) \ 356 356 } \ 357 else if( THEPL->i _size && THEPL->i_enabled ) \357 else if( THEPL->items.i_size && THEPL->i_enabled ) \ 358 358 MIM_SADD( qtr("Play"), "", "", togglePlayPause() ) \ 359 359 \ modules/gui/skins2/commands/cmd_input.cpp
radc858d r799b282 36 36 } 37 37 38 if( pPlaylist->i_size ) 39 { 38 if( !playlist_IsEmpty( pPlaylist ) ) 40 39 playlist_Play( pPlaylist ); 41 }42 40 else 43 41 { src/control/mediacontrol_core.c
r90d2639 r799b282 221 221 222 222 vlc_mutex_lock( &p_playlist->object_lock ); 223 if( p_playlist->i _size )223 if( p_playlist->items.i_size ) 224 224 { 225 225 int i_from; … … 361 361 362 362 vlc_mutex_lock( &p_playlist->object_lock ); 363 i_playlist_size = p_playlist->i _size;363 i_playlist_size = p_playlist->items.i_size; 364 364 365 365 retval = mediacontrol_PlaylistSeq__alloc( i_playlist_size ); … … 367 367 for( i_index = 0 ; i_index < i_playlist_size ; i_index++ ) 368 368 { 369 retval->data[i_index] = strdup( p_playlist->pp_items[i_index]->p_input->psz_uri );369 retval->data[i_index] = strdup( ARRAY_VAL(p_playlist->items, i_index)->p_input->psz_uri ); 370 370 } 371 371 vlc_mutex_unlock( &p_playlist->object_lock ); src/control/playlist.c
r822485d r799b282 45 45 ///\todo Handle additionnal options 46 46 47 if( PL->i _size == 0 ) RAISEVOID( "Empty playlist" );47 if( PL->items.i_size == 0 ) RAISEVOID( "Empty playlist" ); 48 48 if( i_id > 0 ) 49 49 { … … 137 137 { 138 138 assert( PL ); 139 return PL->i _size;139 return PL->items.i_size; 140 140 } 141 141 src/input/item.c
r2ffa2bd r799b282 77 77 input_ItemClean( p_input ); 78 78 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 } 79 ARRAY_BSEARCH( p_playlist->input_items,->i_id, int, p_input->i_id, i); 80 if( i != -1 ) 81 ARRAY_REMOVE( p_playlist->input_items, i); 82 88 83 pl_Release( p_obj ); 89 84 free( p_input ); … … 187 182 input_item_t *input_ItemGetById( playlist_t *p_playlist, int i_id ) 188 183 { 189 int i, i_top, i_bottom; 190 i_bottom = 0; i_top = p_playlist->i_input_items -1; 191 i = i_top /2 ; 192 while( p_playlist->pp_input_items[i]->i_id != i_id && 193 i_top > i_bottom ) 194 { 195 if( p_playlist->pp_input_items[i]->i_id < i_id ) 196 i_bottom = i + 1; 197 else 198 i_top = i - 1; 199 i = i_bottom + ( i_top - i_bottom ) / 2; 200 } 201 if( p_playlist->pp_input_items[i]->i_id == i_id ) 202 { 203 return p_playlist->pp_input_items[i]; 204 } 184 int i; 185 ARRAY_BSEARCH( p_playlist->input_items, ->i_id, int, i_id, i); 186 if( i != -1 ) 187 return ARRAY_VAL( p_playlist->input_items, i); 205 188 return NULL; 206 189 } … … 229 212 PL_LOCK; 230 213 p_input->i_id = ++p_playlist->i_last_input_id; 231 TAB_APPEND( p_playlist->i_input_items, 232 p_playlist->pp_input_items, 233 p_input ); 214 ARRAY_APPEND( p_playlist->input_items, p_input ); 234 215 PL_UNLOCK; 235 216 pl_Release( p_obj ); src/libvlc.c
r2ffa2bd r799b282 671 671 int i_size; 672 672 LIBVLC_PLAYLIST_FUNC; 673 i_size = p_libvlc->p_playlist->i _size;673 i_size = p_libvlc->p_playlist->items.i_size; 674 674 LIBVLC_PLAYLIST_FUNC_END; 675 675 return i_size; src/playlist/control.c
reb463ca r799b282 85 85 vlc_value_t val; 86 86 87 if( p_playlist->i_size <= 0 ) 88 { 87 if( p_playlist->items.i_size <= 0 ) 89 88 return VLC_EGENERIC; 90 }91 89 92 90 switch( i_query ) … … 101 99 // Item null = take the first child of node 102 100 case PLAYLIST_VIEWPLAY: 103 p_playlist->b_reset_random = VLC_TRUE;104 101 p_node = (playlist_item_t *)va_arg( args, playlist_item_t * ); 105 102 p_item = (playlist_item_t *)va_arg( args, playlist_item_t * ); … … 114 111 p_playlist->request.p_node = p_node; 115 112 p_playlist->request.p_item = p_item; 113 if( p_item && var_GetBool( p_playlist, "random" ) ) 114 p_playlist->b_reset_currently_playing = VLC_TRUE; 116 115 break; 117 116 … … 262 261 *****************************************************************************/ 263 262 263 static void ResyncCurrentIndex(playlist_t *p_playlist, playlist_item_t *p_cur ) 264 { 265 PL_DEBUG("resyncing on %s", PLI_NAME(p_cur) ); 266 /* Simply resync index */ 267 int i; 268 p_playlist->i_current_index = -1; 269 for( i = 0 ; i< p_playlist->current.i_size; i++ ) 270 { 271 if( ARRAY_VAL(p_playlist->current, i) == p_cur ) 272 { 273 p_playlist->i_current_index = i; 274 break; 275 } 276 } 277 PL_DEBUG("%s is at %i", PLI_NAME(p_cur), p_playlist->i_current_index ); 278 } 279 280 static void ResetCurrentlyPlaying( playlist_t *p_playlist, vlc_bool_t b_random, 281 playlist_item_t *p_cur ) 282 { 283 playlist_item_t *p_next = NULL; 284 PL_DEBUG("rebuilding array of current - root %s", 285 PLI_NAME(p_playlist->status.p_node) ); 286 ARRAY_RESET(p_playlist->current); 287 p_playlist->i_current_index = -1; 288 while( 1 ) 289 { 290 /** FIXME: this is *slow* */ 291 p_next = playlist_GetNextLeaf( p_playlist, 292 p_playlist->status.p_node, 293 p_next, VLC_TRUE, VLC_FALSE ); 294 if( p_next ) 295 { 296 if( p_next == p_cur ) 297 p_playlist->i_current_index = p_playlist->current.i_size; 298 ARRAY_APPEND( p_playlist->current, p_next); 299 } 300 else break; 301 } 302 PL_DEBUG("rebuild done - %i items, index %i", p_playlist->current.i_size, 303 p_playlist->i_current_index); 304 if( b_random ) 305 { 306 /* Shuffle the array */ 307 srand( (unsigned int)mdate() ); 308 int swap = 0; 309 int j; 310 for( j = p_playlist->current.i_size - 1; j > 0; j-- ) 311 { 312 swap++; 313 int i = rand() % (j+1); /* between 0 and j */ 314 playlist_item_t *p_tmp; 315 p_tmp = ARRAY_VAL(p_playlist->current, i); 316 ARRAY_VAL(p_playlist->current,i) = ARRAY_VAL(p_playlist->current,j); 317 ARRAY_VAL(p_playlist->current,j) = p_tmp; 318 } 319 } 320 p_playlist->b_reset_currently_playing = VLC_FALSE; 321 } 322 264 323 /** This function calculates the next playlist item, depending 265 324 * on the playlist course mode (forward, backward, random, view,...). */ … … 276 335 /* Handle quickly a few special cases */ 277 336 /* No items to play */ 278 if( p_playlist->i _size == 0 )337 if( p_playlist->items.i_size == 0 ) 279 338 { 280 339 msg_Info( p_playlist, "playlist is empty" ); … … 309 368 } 310 369 311 /* Random case. This is an exception: if request, but request is skip +- 1312 * we don't go to next item but select a new random one. */313 if( b_random &&314 ( !p_playlist->request.b_request ||315 ( p_playlist->request.b_request &&316 ( p_playlist->request.p_item == NULL ||317 p_playlist->request.i_skip == 1 ||318 p_playlist->request.i_skip == -1 ) ) ) )319 {320 PL_DEBUG( "doing random, have %i items, currently at %i, reset %i\n",321 p_playlist->i_random, p_playlist->i_random_index,322 p_playlist->b_reset_random );323 if( p_playlist->b_reset_random )324 {325 int j;326 FREE( p_playlist->pp_random );327 if( !p_playlist->b_reset_random && !b_loop ) goto end;328 p_playlist->i_random = 0;329 p_playlist->i_random_index = 0;330 p_playlist->i_random = playlist_GetAllEnabledChildren(331 p_playlist,332 p_playlist->status.p_node,333 &p_playlist->pp_random );334 /* Shuffle the array */335 srand( (unsigned int)mdate() );336 int swap = 0;337 for( j = p_playlist->i_random -1; j > 0; j-- )338 {339 swap++;340 int i = rand() % (j+1); /* between 0 and j */341 playlist_item_t *p_tmp;342 p_tmp = p_playlist->pp_random[i];343 p_playlist->pp_random[i] = p_playlist->pp_random[j];344 p_playlist->pp_random[j] = p_tmp;345 }346 p_playlist->b_reset_random = VLC_FALSE;347 PL_DEBUG( "random rebuilt, have %i items", p_playlist->i_random );348 }349 else350 {351 /* Go backward or forward */352 if( !p_playlist->request.b_request || !p_playlist->request.p_item ||353 p_playlist->request.i_skip == 1 )354 p_playlist->i_random_index++;355 else356 p_playlist->i_random_index--;357 /* Handle bounds situations */358 if( p_playlist->i_random_index == -1 )359 {360 if( !b_loop || p_playlist->i_random == 0 ) goto end;361 p_playlist->i_random_index = p_playlist->i_random - 1;362 }363 else if( p_playlist->i_random_index == p_playlist->i_random )364 {365 if( !b_loop || p_playlist->i_random == 0 ) goto end;366 p_playlist->i_random_index = 0;367 }368 }369 PL_DEBUG( "using random item %i", p_playlist->i_random_index );370 if ( p_playlist->i_random == 0 ) goto end; /* Can this happen ?? */371 p_new = p_playlist->pp_random[p_playlist->i_random_index];372 end:373 if( !p_new ) p_playlist->b_reset_random = VLC_TRUE;374 p_playlist->request.i_skip = 0;375 p_playlist->request.b_request = VLC_FALSE;376 return p_new;377 }378 379 370 /* Start the real work */ 380 371 if( p_playlist->request.b_request ) … … 386 377 PLI_NAME( p_playlist->request.p_node ), i_skip ); 387 378 388 if( p_playlist->request.p_node ) 379 if( p_playlist->request.p_node && 380 p_playlist->request.p_node != p_playlist->status.p_node ) 381 { 389 382 p_playlist->status.p_node = p_playlist->request.p_node; 383 p_playlist->b_reset_currently_playing = VLC_TRUE; 384 } 390 385 391 386 /* If we are asked for a node, dont take it */ … … 393 388 i_skip++; 394 389 395 if( i_skip > 0 ) 390 if( p_playlist->b_reset_currently_playing ) 391 ResetCurrentlyPlaying( p_playlist, b_random, p_new ); 392 else if( p_new ) 393 ResyncCurrentIndex( p_playlist, p_new ); 394 else 395 p_playlist->i_current_index = -1; 396 397 if( p_playlist->current.i_size && i_skip > 0 ) 396 398 { 397 399 for( i = i_skip; i > 0 ; i-- ) 398 400 { 399 p_new = playlist_GetNextLeaf( p_playlist, 400 p_playlist->request.p_node, 401 p_new, VLC_TRUE, VLC_FALSE ); 402 if( p_new == NULL ) 401 p_playlist->i_current_index++; 402 if( p_playlist->i_current_index == p_playlist->current.i_size ) 403 403 { 404 404 PL_DEBUG( "looping - restarting at beginning of node" ); 405 p_new = playlist_GetNextLeaf( p_playlist, 406 p_playlist->request.p_node, 407 NULL, VLC_TRUE, VLC_FALSE); 408 if( p_new == NULL ) break; 405 p_playlist->i_current_index = 0; 409 406 } 410 407 } 411 } 412 else if( i_skip < 0 ) 408 p_new = ARRAY_VAL( p_playlist->current, 409 p_playlist->i_current_index ); 410 } 411 else if( p_playlist->current.i_size && i_skip < 0 ) 413 412 { 414 413 for( i = i_skip; i < 0 ; i++ ) 415 414 { 416 p_new = playlist_GetPrevLeaf( p_playlist, 417 p_playlist->request.p_node, 418 p_new, VLC_FALSE, VLC_FALSE ); 419 if( p_new == NULL ) 415 p_playlist->i_current_index--; 416 if( p_playlist->i_current_index == -1 ) 420 417 { 421 418 PL_DEBUG( "looping - restarting at end of node" ); 422 /** \bug This is needed because GetPrevLeaf does not loop 423 * by itself */ 424 p_new = playlist_GetLastLeaf( p_playlist, 425 p_playlist->request.p_node ); 419 p_playlist->i_current_index = p_playlist->current.i_size-1; 426 420 } 427 if( p_new == NULL ) break;428 421 } 422 p_new = ARRAY_VAL( p_playlist->current, 423 p_playlist->i_current_index ); 429 424 } 430 425 /* Clear the request */ … … 434 429 else 435 430 { 436 PL_DEBUG( "changing item without a request" ); 431 PL_DEBUG( "changing item without a request (current %i/%i)", 432 p_playlist->i_current_index, p_playlist->current.i_size ); 437 433 /* Cant go to next from current item */ 438 434 if( p_playlist->status.p_item && … … 440 436 return NULL; 441 437 442 p_new = playlist_GetNextLeaf( p_playlist, 443 p_playlist->status.p_node, 444 p_playlist->status.p_item, 445 VLC_TRUE, VLC_FALSE ); 446 if( p_new == NULL && b_loop ) 447 { 448 PL_DEBUG( "looping" ); 449 p_new = playlist_GetNextLeaf( p_playlist, 450 p_playlist->status.p_node, 451 NULL, VLC_TRUE, VLC_FALSE ); 452 } 438 if( p_playlist->b_reset_currently_playing ) 439 ResetCurrentlyPlaying( p_playlist, b_random, 440 p_playlist->status.p_item ); 441 442 p_playlist->i_current_index++; 443 if( p_playlist->i_current_index == p_playlist->current.i_size ) 444 { 445 if( !b_loop || p_playlist->current.i_size == 0 ) return NULL; 446 p_playlist->i_current_index = 0; 447 } 448 PL_DEBUG( "using item %i", p_playlist->i_current_index ); 449 if ( p_playlist->current.i_size == 0 ) return NULL; 450 451 p_new = ARRAY_VAL( p_playlist->current, p_playlist->i_current_index ); 453 452 /* The new item can't be autoselected */ 454 453 if( p_new != NULL && p_new->i_flags & PLAYLIST_SKIP_FLAG ) 455 454 return NULL; 456 }457 if( p_new == NULL )458 {459 msg_Dbg( p_playlist, "did not find something to play" );460 455 } 461 456 return p_new; src/playlist/engine.c
r4e03ca0 r799b282 35 35 static void VariablesInit( playlist_t *p_playlist ); 36 36 37 static int RandomCallback( vlc_object_t *p_this, char const *psz_cmd, 38 vlc_value_t oldval, vlc_value_t newval, void *a ) 39 { 40 ((playlist_t*)p_this)->b_reset_currently_playing = VLC_TRUE; 41 return VLC_SUCCESS; 42 } 43 37 44 /** 38 45 * Create playlist … … 67 74 p_playlist->i_sout_destroyed_date = 0; 68 75 69 p_playlist->i_size = 0; 70 p_playlist->pp_items = NULL; 71 p_playlist->i_all_size = 0; 72 p_playlist->pp_all_items = NULL; 73 74 p_playlist->i_input_items = 0; 75 p_playlist->pp_input_items = NULL; 76 77 p_playlist->i_random = 0; 78 p_playlist->pp_random = NULL; 79 p_playlist->i_random_index = 0; 80 p_playlist->b_reset_random = VLC_TRUE; 76 ARRAY_INIT( p_playlist->items ); 77 ARRAY_INIT( p_playlist->all_items ); 78 ARRAY_INIT( p_playlist->input_items ); 79 ARRAY_INIT( p_playlist->current ); 80 81 p_playlist->i_current_index = 0; 82 p_playlist->b_reset_currently_playing = VLC_TRUE; 81 83 82 84 i_tree = var_CreateGetBool( p_playlist, "playlist-tree" ); … … 163 165 164 166 PL_LOCK; 165 playlist_NodeDelete( p_playlist, p_playlist->p_root_category, VLC_TRUE, 166 VLC_TRUE ); 167 playlist_NodeDelete( p_playlist, p_playlist->p_root_onelevel, VLC_TRUE, 168 VLC_TRUE ); 167 /* Go through all items, and simply free everything without caring 168 * about the tree structure. Do not decref, it will be done by doing 169 * the same thing on the input items array */ 170 FOREACH_ARRAY( playlist_item_t *p_del, p_playlist->all_items ) 171 free( p_del->pp_children ); 172 free( p_del ); 173 FOREACH_END(); 174 ARRAY_RESET( p_playlist->all_items ); 175 176 FOREACH_ARRAY( input_item_t *p_del, p_playlist->input_items ) 177 input_ItemClean( p_del ); 178 free( p_del ); 179 FOREACH_END(); 180 ARRAY_RESET( p_playlist->input_items ); 181 182 ARRAY_RESET( p_playlist->items ); 183 ARRAY_RESET( p_playlist->current ); 184 169 185 PL_UNLOCK; 170 186 … … 636 652 var_CreateGetBool( p_playlist, "repeat" ); 637 653 var_CreateGetBool( p_playlist, "loop" ); 638 } 654 655 var_AddCallback( p_playlist, "random", RandomCallback, NULL ); 656 } src/playlist/item.c
rdfd24ab r799b282 404 404 p_playlist->p_root_onelevel, VLC_FALSE ); 405 405 } 406 p_playlist->b_reset_ random= VLC_TRUE;406 p_playlist->b_reset_currently_playing = VLC_TRUE; 407 407 var_SetInteger( p_playlist, "item-change", p_item_in_category-> 408 408 p_input->i_id ); … … 545 545 p_add->i_node = i_node_id; 546 546 val.p_address = p_add; 547 p_playlist->b_reset_ random= VLC_TRUE;547 p_playlist->b_reset_currently_playing = VLC_TRUE; 548 548 var_Set( p_playlist, "item-append", val ); 549 549 free( p_add ); … … 611 611 playlist_item_t *p_node, int i_pos ) 612 612 { 613 INSERT_ELEM( p_playlist->pp_items, p_playlist->i_size, 614 p_playlist->i_size, p_item ); 615 INSERT_ELEM( p_playlist->pp_all_items, p_playlist->i_all_size, 616 p_playlist->i_all_size, p_item ); 613 ARRAY_APPEND(p_playlist->items, p_item); 614 ARRAY_APPEND(p_playlist->all_items, p_item); 617 615 p_playlist->i_enabled ++; 618 616 619 617 if( i_pos == PLAYLIST_END ) 620 {621 618 playlist_NodeAppend( p_playlist, p_item, p_node ); 622 }623 619 else 624 {625 620 playlist_NodeInsert( p_playlist, p_item, p_node, i_pos ); 626 } 621 627 622 if( !p_playlist->b_doing_ml ) 628 623 playlist_SendAddNotify( p_playlist, p_item->i_id, p_node->i_id ); … … 637 632 638 633 /* Remove it from the array of available items */ 639 for( i = 0 ; i < p_playlist->i_size ; i++ ) 640 { 641 if( p_item == p_playlist->pp_items[i] ) 642 { 643 REMOVE_ELEM( p_playlist->pp_items, p_playlist->i_size, i ); 644 } 645 } 634 ARRAY_BSEARCH( p_playlist->items,->i_id, int, p_item->i_id, i ); 635 if( i != -1 ) 636 ARRAY_REMOVE( p_playlist->items, i ); 646 637 } 647 638 … … 650 641 vlc_bool_t b_stop ) 651 642 { 652 int i , i_top, i_bottom;643 int i; 653 644 int i_id = p_item->i_id; 654 645 vlc_bool_t b_flag = VLC_FALSE; … … 658 649 return playlist_NodeDelete( p_playlist, p_item, VLC_TRUE, VLC_FALSE ); 659 650 } 660 p_playlist->b_reset_ random= VLC_TRUE;651 p_playlist->b_reset_currently_playing = VLC_TRUE; 661 652 var_SetInteger( p_playlist, "item-deleted", i_id ); 662 653 663 654 /* Remove the item from the bank */ 664 i_bottom = 0; i_top = p_playlist->i_all_size - 1; 665 i = i_top / 2; 666 while( p_playlist->pp_all_items[i]->i_id != i_id && 667 i_top > i_bottom ) 668 { 669 if( p_playlist->pp_all_items[i]->i_id < i_id ) 670 { 671 i_bottom = i + 1; 672 } 673 else 674 { 675 i_top = i - 1; 676 } 677 i = i_bottom + ( i_top - i_bottom ) / 2; 678 } 679 if( p_playlist->pp_all_items[i]->i_id == i_id ) 680 { 681 REMOVE_ELEM( p_playlist->pp_all_items, p_playlist->i_all_size, i ); 682 } 655 ARRAY_BSEARCH( p_playlist->all_items,->i_id, int, i_id, i ); 656 if( i != -1 ) 657 ARRAY_REMOVE( p_playlist->all_items, i ); 683 658 684 659 /* Check if it is the current item */ src/playlist/search.c
r315069b r799b282
