diff options
Diffstat (limited to 'apps/playback.c')
-rw-r--r-- | apps/playback.c | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/apps/playback.c b/apps/playback.c index 9abc3e38a9..2f67b6c3ba 100644 --- a/apps/playback.c +++ b/apps/playback.c | |||
@@ -438,8 +438,8 @@ void audio_fill_file_buffer(void) | |||
438 | } | 438 | } |
439 | 439 | ||
440 | buf_widx += rc; | 440 | buf_widx += rc; |
441 | if (buf_widx == codecbuflen) | 441 | if (buf_widx >= codecbuflen) |
442 | buf_widx = 0; | 442 | buf_widx -= codecbuflen; |
443 | i += rc; | 443 | i += rc; |
444 | tracks[track_widx].available += rc; | 444 | tracks[track_widx].available += rc; |
445 | fill_bytesleft -= rc; | 445 | fill_bytesleft -= rc; |
@@ -552,7 +552,7 @@ bool loadcodec(const char *trackname, bool start_play) | |||
552 | return false; | 552 | return false; |
553 | buf_widx += rc; | 553 | buf_widx += rc; |
554 | if (buf_widx >= codecbuflen) | 554 | if (buf_widx >= codecbuflen) |
555 | buf_widx = 0; | 555 | buf_widx -= codecbuflen; |
556 | i += rc; | 556 | i += rc; |
557 | } | 557 | } |
558 | close(fd); | 558 | close(fd); |
@@ -598,7 +598,7 @@ bool audio_load_track(int offset, bool start_play, int peek_offset) | |||
598 | 598 | ||
599 | /* Load the codec */ | 599 | /* Load the codec */ |
600 | if (buf_widx >= codecbuflen) | 600 | if (buf_widx >= codecbuflen) |
601 | buf_widx = 0; | 601 | buf_widx -= codecbuflen; |
602 | 602 | ||
603 | tracks[track_widx].codecbuf = &codecbuf[buf_widx]; | 603 | tracks[track_widx].codecbuf = &codecbuf[buf_widx]; |
604 | if (!loadcodec(trackname, start_play)) { | 604 | if (!loadcodec(trackname, start_play)) { |
@@ -742,15 +742,15 @@ bool audio_load_track(int offset, bool start_play, int peek_offset) | |||
742 | } | 742 | } |
743 | buf_widx += rc; | 743 | buf_widx += rc; |
744 | if (buf_widx >= codecbuflen) | 744 | if (buf_widx >= codecbuflen) |
745 | buf_widx = 0; | 745 | buf_widx -= codecbuflen; |
746 | i += rc; | 746 | i += rc; |
747 | tracks[track_widx].available += rc; | 747 | tracks[track_widx].available += rc; |
748 | tracks[track_widx].filerem -= rc; | 748 | tracks[track_widx].filerem -= rc; |
749 | codecbufused += rc; | ||
749 | fill_bytesleft -= rc; | 750 | fill_bytesleft -= rc; |
750 | } | 751 | } |
751 | 752 | ||
752 | tracks[track_widx].filepos = i; | 753 | tracks[track_widx].filepos = i; |
753 | codecbufused += i; | ||
754 | 754 | ||
755 | /* Leave the file handle open for faster buffer refill. */ | 755 | /* Leave the file handle open for faster buffer refill. */ |
756 | if (tracks[track_widx].filerem != 0) { | 756 | if (tracks[track_widx].filerem != 0) { |
@@ -809,8 +809,8 @@ void audio_check_buffer(void) | |||
809 | 809 | ||
810 | /* Fill buffer as full as possible for cross-fader. */ | 810 | /* Fill buffer as full as possible for cross-fader. */ |
811 | #ifndef SIMULATOR | 811 | #ifndef SIMULATOR |
812 | if (cur_ti->id3.length > 0 && | 812 | if (pcm_is_crossfade_enabled() && cur_ti->id3.length > 0 |
813 | cur_ti->id3.length - cur_ti->id3.elapsed < 20000 && playing) | 813 | && cur_ti->id3.length - cur_ti->id3.elapsed < 20000 && playing) |
814 | pcm_set_boost_mode(true); | 814 | pcm_set_boost_mode(true); |
815 | #endif | 815 | #endif |
816 | 816 | ||
@@ -873,6 +873,7 @@ void audio_update_trackinfo(void) | |||
873 | 873 | ||
874 | cur_ti = &tracks[track_ridx]; | 874 | cur_ti = &tracks[track_ridx]; |
875 | buf_ridx += cur_ti->codecsize; | 875 | buf_ridx += cur_ti->codecsize; |
876 | codecbufused -= cur_ti->codecsize; | ||
876 | if (buf_ridx >= codecbuflen) | 877 | if (buf_ridx >= codecbuflen) |
877 | buf_ridx -= codecbuflen; | 878 | buf_ridx -= codecbuflen; |
878 | #ifndef SIMULATOR | 879 | #ifndef SIMULATOR |
@@ -989,7 +990,7 @@ void audio_thread(void) | |||
989 | struct event ev; | 990 | struct event ev; |
990 | 991 | ||
991 | while (1) { | 992 | while (1) { |
992 | yield(); | 993 | sleep(50); |
993 | audio_check_buffer(); | 994 | audio_check_buffer(); |
994 | 995 | ||
995 | queue_wait_w_tmo(&audio_queue, &ev, 10); | 996 | queue_wait_w_tmo(&audio_queue, &ev, 10); |