Randomize the playlist. Definition at line 574 of file playq.c. 00575 { 00576 unsigned int remaining, idx = 0; 00577 struct vfsref *vr, **vrlist; 00578 00579 /* 00580 * This code implements the Fisher-Yates algorithm to randomize 00581 * the playlist. Only difference is that we already place items 00582 * back in the list instead of actually swapping them. 00583 */ 00584 00585 playq_lock(); 00586 remaining = vfs_list_items(&playq_list); 00587 if (remaining < 2) 00588 goto done; 00589 00590 /* Generate a shadow list */ 00591 vrlist = g_new(struct vfsref *, remaining); 00592 VFS_LIST_FOREACH(&playq_list, vr) 00593 vrlist[idx++] = vr; 00594 vfs_list_init(&playq_list); 00595 00596 do { 00597 /* Pick a random item from the beginning */ 00598 idx = g_rand_int_range(playq_rand, 0, remaining); 00599 00600 /* Add it to the list */ 00601 vfs_list_insert_tail(&playq_list, vrlist[idx]); 00602 /* Remove fragmentation */ 00603 vrlist[idx] = vrlist[--remaining]; 00604 } while (remaining != 0); 00605 00606 /* Trash the shadow list */ 00607 g_free(vrlist); 00608 00609 gui_playq_notify_post_randomization(); 00610 gui_playq_notify_done(); 00611 done: playq_unlock(); 00612 }
Here is the call graph for this function:
![]()
Here is the caller graph for this function:
![]() |
1.6.3