Skip to content

Commit

Permalink
Cleaning up player_skip_song
Browse files Browse the repository at this point in the history
  • Loading branch information
jaltenmueller committed Jan 2, 2012
1 parent 0f7330d commit b8c9e0a
Showing 1 changed file with 8 additions and 51 deletions.
59 changes: 8 additions & 51 deletions player.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -162,50 +162,16 @@ player_seek(int seconds)
player.seek(seconds); player.seek(seconds);
} }


/* TODO merge this with the player_play_prev_song into player_skip_song */
void void
player_play_next_song(int skip) player_skip_song(int num)
{
if (!player.playing())
return;

switch (player_info.mode) {
case MODE_LINEAR:
player_info.qidx += skip;
if (player_info.qidx >= player_info.queue->nfiles) {
player_info.qidx = 0;
player_stop();
} else
player_play();

break;

case MODE_LOOP:
player_info.qidx += skip;
if (player_info.qidx >= player_info.queue->nfiles)
player_info.qidx %= player_info.queue->nfiles;

player_play();
break;

case MODE_RANDOM:
player_info.qidx = rand() % player_info.queue->nfiles;
player_play();
break;
}
}

/* TODO (see comment for player_play_next_song) */
void
player_play_prev_song(int skip)
{ {
if (!player.playing()) if (!player.playing())
return; return;


switch (player_info.mode) { switch (player_info.mode) {
case MODE_LINEAR: case MODE_LINEAR:
player_info.qidx -= skip; player_info.qidx += num;
if (player_info.qidx < 0) { if (player_info.qidx >= player_info.queue->nfiles || player_info.qidx < 0) {
player_info.qidx = 0; player_info.qidx = 0;
player_stop(); player_stop();
} else } else
Expand All @@ -214,11 +180,12 @@ player_play_prev_song(int skip)
break; break;


case MODE_LOOP: case MODE_LOOP:
skip %= player_info.queue->nfiles; player_info.qidx += num;
if (skip <= player_info.qidx) if ( player_info.qidx < 0 )
player_info.qidx -= skip; player_info.qidx += ( abs( player_info.qidx / player_info.queue->nfiles ) + 1 )
* player_info.queue->nfiles;
else else
player_info.qidx = player_info.queue->nfiles - (skip + player_info.qidx); player_info.qidx %= player_info.queue->nfiles;


player_play(); player_play();
break; break;
Expand All @@ -230,16 +197,6 @@ player_play_prev_song(int skip)
} }
} }


/* TODO merge with above... wtf didn't i do it that way!? */
void
player_skip_song(int num)
{
if (num >= 0)
player_play_next_song(num);
else
player_play_prev_song(num * -1);
}

void void
player_volume_step(float percent) player_volume_step(float percent)
{ {
Expand Down

0 comments on commit b8c9e0a

Please sign in to comment.