diff options
Diffstat (limited to 'apps/codecs')
-rw-r--r-- | apps/codecs/mpa.c | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/apps/codecs/mpa.c b/apps/codecs/mpa.c index 3ee2b352f1..2c946f3f0d 100644 --- a/apps/codecs/mpa.c +++ b/apps/codecs/mpa.c | |||
@@ -101,6 +101,12 @@ enum codec_status codec_start(struct codec_api *api) | |||
101 | ci->configure(DSP_SET_CLIP_MAX, (int *)(MAD_F_ONE - 1)); | 101 | ci->configure(DSP_SET_CLIP_MAX, (int *)(MAD_F_ONE - 1)); |
102 | ci->configure(CODEC_SET_FILEBUF_CHUNKSIZE, (int *)(1024*16)); | 102 | ci->configure(CODEC_SET_FILEBUF_CHUNKSIZE, (int *)(1024*16)); |
103 | 103 | ||
104 | /** This label might need to be moved above all the init code, but I don't | ||
105 | * think reiniting the codec is necessary for MPEG. It might even be unwanted | ||
106 | * for gapless playback. | ||
107 | * Reinitializing seems to be necessary to avoid playback quircks when seeking. */ | ||
108 | next_track: | ||
109 | |||
104 | ci->memset(&stream, 0, sizeof(struct mad_stream)); | 110 | ci->memset(&stream, 0, sizeof(struct mad_stream)); |
105 | ci->memset(&frame, 0, sizeof(struct mad_frame)); | 111 | ci->memset(&frame, 0, sizeof(struct mad_frame)); |
106 | ci->memset(&synth, 0, sizeof(struct mad_synth)); | 112 | ci->memset(&synth, 0, sizeof(struct mad_synth)); |
@@ -114,10 +120,6 @@ enum codec_status codec_start(struct codec_api *api) | |||
114 | frame.overlap = &mad_frame_overlap; | 120 | frame.overlap = &mad_frame_overlap; |
115 | stream.main_data = &mad_main_data; | 121 | stream.main_data = &mad_main_data; |
116 | 122 | ||
117 | /* This label might need to be moved above all the init code, but I don't | ||
118 | think reiniting the codec is necessary for MPEG. It might even be unwanted | ||
119 | for gapless playback */ | ||
120 | next_track: | ||
121 | file_end = 0; | 123 | file_end = 0; |
122 | while (!*ci->taginfo_ready && !ci->stop_codec) | 124 | while (!*ci->taginfo_ready && !ci->stop_codec) |
123 | ci->sleep(1); | 125 | ci->sleep(1); |
@@ -156,14 +158,21 @@ next_track: | |||
156 | 158 | ||
157 | samplesdone = ((int64_t) (ci->seek_time - 1)) | 159 | samplesdone = ((int64_t) (ci->seek_time - 1)) |
158 | * current_frequency / 1000; | 160 | * current_frequency / 1000; |
159 | newpos = ci->mp3_get_filepos(ci->seek_time-1) + | 161 | |
160 | ci->id3->first_frame_offset; | 162 | if (ci->seek_time-1 == 0) |
163 | newpos = 0; | ||
164 | else | ||
165 | newpos = ci->mp3_get_filepos(ci->seek_time-1) + | ||
166 | ci->id3->first_frame_offset; | ||
161 | 167 | ||
162 | if (!ci->seek_buffer(newpos)) | 168 | if (!ci->seek_buffer(newpos)) |
163 | goto next_track; | 169 | goto next_track; |
164 | if (newpos == 0) | ||
165 | samples_to_skip = start_skip; | ||
166 | ci->seek_complete(); | 170 | ci->seek_complete(); |
171 | if (newpos == 0) | ||
172 | { | ||
173 | ci->id3->elapsed = 0; | ||
174 | goto next_track; | ||
175 | } | ||
167 | } | 176 | } |
168 | 177 | ||
169 | /* Lock buffers */ | 178 | /* Lock buffers */ |