- if(q->state == playing_random)
- return 0;
- /* Try to pick a random track */
- if(!(p = trackdb_random(16)))
- return -1;
- /* Add it to the end of the queue. */
- q = queue_add(p, 0, WHERE_END);
- q->state = playing_random;
+ ++qlen;
+ /* Add random tracks until the queue is at the right size */
+ while(qlen < config->queue_pad) {
+ /* Try to pick a random track */
+ if(!(p = trackdb_random(16))) {
+ rc = -1;
+ break;
+ }
+ /* Add it to the end of the queue. */
+ q = queue_add(p, 0, WHERE_END);
+ q->state = playing_random;
+ D(("picked %p (%s) at random", (void *)q, q->track));
+ ++qlen;
+ }