libsaria: Don't use random if playlist size == 1
This could cause a floating point exception when I mod-by-zero... Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
This commit is contained in:
parent
1205a94aa7
commit
83f8b1e543
|
@ -99,17 +99,19 @@ namespace libsaria
|
|||
Track *Playlist::next()
|
||||
{
|
||||
Track *track;
|
||||
unsigned int size = get_size();
|
||||
|
||||
if (get_size() == 0)
|
||||
if (size == 0)
|
||||
return NULL;
|
||||
|
||||
if (check_flag(PL_RANDOM))
|
||||
else if (size == 1)
|
||||
cur = 0;
|
||||
else if (check_flag(PL_RANDOM))
|
||||
cur += rand() % ((get_size() * 3) / 4);
|
||||
else if (flags & PL_NO_DRAIN)
|
||||
cur++;
|
||||
|
||||
if (cur >= plist.size())
|
||||
cur -= plist.size();
|
||||
if (cur >= size)
|
||||
cur -= size;
|
||||
|
||||
track = plist[cur];
|
||||
if (!(flags & PL_NO_DRAIN))
|
||||
|
|
Loading…
Reference in New Issue