summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
Diffstat (limited to 'apps')
-rw-r--r--apps/playback.c23
1 files changed, 17 insertions, 6 deletions
diff --git a/apps/playback.c b/apps/playback.c
index 495629e5ea..a74eee1dbd 100644
--- a/apps/playback.c
+++ b/apps/playback.c
@@ -2039,7 +2039,6 @@ static bool audio_yield_codecs(void)
2039 return false; 2039 return false;
2040} 2040}
2041 2041
2042/* Note that this function might yield(). */
2043static void audio_clear_track_entries(bool clear_unbuffered) 2042static void audio_clear_track_entries(bool clear_unbuffered)
2044{ 2043{
2045 int cur_idx = track_widx; 2044 int cur_idx = track_widx;
@@ -2140,6 +2139,7 @@ static bool audio_read_file(size_t minimum)
2140 /* copy_n is the largest chunk that is safe to read */ 2139 /* copy_n is the largest chunk that is safe to read */
2141 copy_n = MIN(conf_filechunk, filebuflen - buf_widx); 2140 copy_n = MIN(conf_filechunk, filebuflen - buf_widx);
2142 2141
2142 /* buf_widx == buf_ridx is defined as buffer empty, not buffer full */
2143 if (RINGBUF_ADD_CROSS(buf_widx,copy_n,buf_ridx) >= 0) 2143 if (RINGBUF_ADD_CROSS(buf_widx,copy_n,buf_ridx) >= 0)
2144 break; 2144 break;
2145 2145
@@ -2158,7 +2158,16 @@ static bool audio_read_file(size_t minimum)
2158 tracks[track_widx].filerem -= rc; 2158 tracks[track_widx].filerem -= rc;
2159 2159
2160 /* How much of the playing track did we overwrite */ 2160 /* How much of the playing track did we overwrite */
2161 overlap = RINGBUF_ADD_CROSS(buf_widx,rc,CUR_TI->buf_idx); 2161 if (buf_widx == CUR_TI->buf_idx)
2162 {
2163 /* Special handling; zero or full overlap? */
2164 if (CUR_TI->filerem)
2165 overlap = rc;
2166 else
2167 overlap=0;
2168 }
2169 else
2170 overlap = RINGBUF_ADD_CROSS(buf_widx,rc,CUR_TI->buf_idx);
2162 2171
2163 /* Advance buffer */ 2172 /* Advance buffer */
2164 buf_widx = RINGBUF_ADD(buf_widx, rc); 2173 buf_widx = RINGBUF_ADD(buf_widx, rc);
@@ -2844,6 +2853,7 @@ skip_done:
2844 2853
2845static void audio_rebuffer_and_seek(size_t newpos) 2854static void audio_rebuffer_and_seek(size_t newpos)
2846{ 2855{
2856 size_t real_preseek;
2847 int fd; 2857 int fd;
2848 char *trackname; 2858 char *trackname;
2849 2859
@@ -2877,24 +2887,25 @@ static void audio_rebuffer_and_seek(size_t newpos)
2877 { 2887 {
2878 CUR_TI->start_pos = newpos - conf_preseek; 2888 CUR_TI->start_pos = newpos - conf_preseek;
2879 CUR_TI->filerem = CUR_TI->filesize - CUR_TI->start_pos; 2889 CUR_TI->filerem = CUR_TI->filesize - CUR_TI->start_pos;
2880 newpos = conf_preseek; 2890 real_preseek = conf_preseek;
2881 } 2891 }
2882 else 2892 else
2883 { 2893 {
2884 CUR_TI->start_pos = 0; 2894 CUR_TI->start_pos = 0;
2885 CUR_TI->filerem = CUR_TI->filesize; 2895 CUR_TI->filerem = CUR_TI->filesize;
2896 real_preseek = newpos;
2886 } 2897 }
2887 2898
2888 CUR_TI->available = 0; 2899 CUR_TI->available = 0;
2889 2900
2890 lseek(current_fd, CUR_TI->start_pos, SEEK_SET); 2901 lseek(current_fd, CUR_TI->start_pos, SEEK_SET);
2891 2902
2892 audio_read_file(newpos); 2903 audio_read_file(real_preseek);
2893 2904
2894 /* Account for the data we just read that is 'behind' us now */ 2905 /* Account for the data we just read that is 'behind' us now */
2895 CUR_TI->available -= newpos; 2906 CUR_TI->available -= real_preseek;
2896 2907
2897 buf_ridx = RINGBUF_ADD(buf_ridx, newpos); 2908 buf_ridx = RINGBUF_ADD(buf_ridx, real_preseek);
2898 2909
2899 LOGFQUEUE("audio > codec Q_CODEC_REQUEST_COMPLETE"); 2910 LOGFQUEUE("audio > codec Q_CODEC_REQUEST_COMPLETE");
2900 queue_post(&codec_callback_queue, Q_CODEC_REQUEST_COMPLETE, 0); 2911 queue_post(&codec_callback_queue, Q_CODEC_REQUEST_COMPLETE, 0);