diff options
Diffstat (limited to 'apps/playback.c')
-rw-r--r-- | apps/playback.c | 40 |
1 files changed, 27 insertions, 13 deletions
diff --git a/apps/playback.c b/apps/playback.c index bebbfb1e43..d3c4b46a99 100644 --- a/apps/playback.c +++ b/apps/playback.c | |||
@@ -179,6 +179,7 @@ static unsigned long prev_track_elapsed = 0; /* Previous track elapsed time (C/A | |||
179 | 179 | ||
180 | /* Track change controls */ | 180 | /* Track change controls */ |
181 | bool automatic_skip = false; /* Who initiated in-progress skip? (C/A-) */ | 181 | bool automatic_skip = false; /* Who initiated in-progress skip? (C/A-) */ |
182 | extern bool track_transition; /* Are we in a track transition? */ | ||
182 | static bool dir_skip = false; /* Is a directory skip pending? (A) */ | 183 | static bool dir_skip = false; /* Is a directory skip pending? (A) */ |
183 | static bool new_playlist = false; /* Are we starting a new playlist? (A) */ | 184 | static bool new_playlist = false; /* Are we starting a new playlist? (A) */ |
184 | static int wps_offset = 0; /* Pending track change offset, to keep WPS responsive (A) */ | 185 | static int wps_offset = 0; /* Pending track change offset, to keep WPS responsive (A) */ |
@@ -223,10 +224,31 @@ static void audio_stop_playback(void); | |||
223 | 224 | ||
224 | /**************************************/ | 225 | /**************************************/ |
225 | 226 | ||
226 | /* Post message from pcmbuf callback in the codec thread that | 227 | /* Between the codec and PCM track change, we need to keep updating the |
227 | * the end of the previous track has just been played. */ | 228 | "elapsed" value of the previous (to the codec, but current to the |
229 | user/PCM/WPS) track, so that the progressbar reaches the end. | ||
230 | During that transition, the WPS will display othertrack_id3. */ | ||
231 | void audio_pcmbuf_position_callback(size_t size) | ||
232 | { | ||
233 | /* This is called from an ISR, so be quick */ | ||
234 | unsigned int time = size * 1000 / 4 / NATIVE_FREQUENCY + | ||
235 | othertrack_id3->elapsed; | ||
236 | |||
237 | if (time >= othertrack_id3->length) | ||
238 | { | ||
239 | if(track_transition){logf("playback: (callback) track transition false");} | ||
240 | track_transition = false; | ||
241 | othertrack_id3->elapsed = othertrack_id3->length; | ||
242 | } | ||
243 | else | ||
244 | othertrack_id3->elapsed = time; | ||
245 | } | ||
246 | |||
247 | /* Post message from pcmbuf that the end of the previous track | ||
248 | * has just been played. */ | ||
228 | void audio_post_track_change(void) | 249 | void audio_post_track_change(void) |
229 | { | 250 | { |
251 | LOGFQUEUE("pcmbuf > pcmbuf Q_AUDIO_TRACK_CHANGED"); | ||
230 | queue_post(&pcmbuf_queue, Q_AUDIO_TRACK_CHANGED, 0); | 252 | queue_post(&pcmbuf_queue, Q_AUDIO_TRACK_CHANGED, 0); |
231 | } | 253 | } |
232 | 254 | ||
@@ -248,16 +270,6 @@ static bool pcmbuf_queue_scan(struct queue_event *ev) | |||
248 | return false; | 270 | return false; |
249 | } | 271 | } |
250 | 272 | ||
251 | /* Clear the pcmbuf queue of messages | ||
252 | * Permissible Context(s): Thread | ||
253 | */ | ||
254 | static void pcmbuf_queue_clear(void) | ||
255 | { | ||
256 | pcm_play_lock(); | ||
257 | queue_clear(&pcmbuf_queue); | ||
258 | pcm_play_unlock(); | ||
259 | } | ||
260 | |||
261 | /* --- Helper functions --- */ | 273 | /* --- Helper functions --- */ |
262 | 274 | ||
263 | static struct mp3entry *bufgetid3(int handle_id) | 275 | static struct mp3entry *bufgetid3(int handle_id) |
@@ -1617,7 +1629,9 @@ static void audio_stop_codec_flush(void) | |||
1617 | if (pcm_is_playing()) | 1629 | if (pcm_is_playing()) |
1618 | { | 1630 | { |
1619 | pcmbuf_play_stop(); | 1631 | pcmbuf_play_stop(); |
1620 | pcmbuf_queue_clear(); | 1632 | pcm_play_lock(); |
1633 | queue_clear(&pcmbuf_queue); | ||
1634 | pcm_play_unlock(); | ||
1621 | } | 1635 | } |
1622 | pcmbuf_pause(paused); | 1636 | pcmbuf_pause(paused); |
1623 | } | 1637 | } |