//
// Naive play queue. Linear array, current index. Shuffle/repeat punted.
// audio_play_track is now async (returns void); the queue just fires the
// download and trusts it to land.
//

Queue :: struct {
    tracks:  [..] Track;
    current: int = -1;
}

queue: Queue;

queue_clear :: () {
    array_reset(*queue.tracks);
    queue.current = -1;
}

queue_add :: (track: Track) {
    array_add(*queue.tracks, track);
}

queue_play_index :: (index: int) -> bool {
    if index < 0 || index >= queue.tracks.count  return false;
    queue.current = index;
    audio_play_track(queue.tracks[index]);
    return true;
}

queue_next :: () -> bool {
    return queue_play_index(queue.current + 1);
}

queue_prev :: () -> bool {
    return queue_play_index(queue.current - 1);
}
