forked from len0rd/rockbox
Second part of FS#8104 by Bertrik Sikken: Simplification of audio_track_count, audio_have_tracks and audio_have_free_tracks. This hopefully won't affect anything, but the semantics of the functions have changed slightly.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15693 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
3947b0c632
commit
d3b8245ca8
2 changed files with 9 additions and 21 deletions
|
@ -344,7 +344,7 @@ static bool dbg_buffering_thread(void)
|
|||
snprintf(buf, sizeof(buf), "data_rem: %ld", (long)d.data_rem);
|
||||
lcd_puts(0, line++, buf);
|
||||
|
||||
snprintf(buf, sizeof(buf), "track count: %2d", audio_track_count()-1);
|
||||
snprintf(buf, sizeof(buf), "track count: %2d", audio_track_count());
|
||||
lcd_puts(0, line++, buf);
|
||||
|
||||
snprintf(buf, sizeof(buf), "handle count: %d", (int)d.num_handles);
|
||||
|
|
|
@ -1422,32 +1422,20 @@ static void codec_thread(void)
|
|||
|
||||
static bool audio_have_tracks(void)
|
||||
{
|
||||
return track_ridx != track_widx || CUR_TI->filesize;
|
||||
return (audio_track_count() != 0);
|
||||
}
|
||||
|
||||
static bool audio_have_free_tracks(void)
|
||||
static int audio_free_track_count(void)
|
||||
{
|
||||
if (track_widx < track_ridx)
|
||||
return track_widx + 1 < track_ridx;
|
||||
else if (track_ridx == 0)
|
||||
return track_widx < MAX_TRACK - 1;
|
||||
|
||||
return true;
|
||||
/* Used tracks + free tracks adds up to MAX_TRACK - 1 */
|
||||
return MAX_TRACK - 1 - audio_track_count();
|
||||
}
|
||||
|
||||
int audio_track_count(void)
|
||||
{
|
||||
if (audio_have_tracks())
|
||||
{
|
||||
int relative_track_widx = track_widx;
|
||||
|
||||
if (track_ridx > track_widx)
|
||||
relative_track_widx += MAX_TRACK;
|
||||
|
||||
return relative_track_widx - track_ridx + 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
/* Calculate difference from track_ridx to track_widx
|
||||
* taking into account a possible wrap-around. */
|
||||
return (MAX_TRACK + track_widx - track_ridx) & MAX_TRACK_MASK;
|
||||
}
|
||||
|
||||
long audio_filebufused(void)
|
||||
|
@ -1659,7 +1647,7 @@ static bool audio_load_track(int offset, bool start_play)
|
|||
/* Stop buffer filling if there is no free track entries.
|
||||
Don't fill up the last track entry (we wan't to store next track
|
||||
metadata there). */
|
||||
if (!audio_have_free_tracks())
|
||||
if (!audio_free_track_count())
|
||||
{
|
||||
logf("No free tracks");
|
||||
return false;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue