summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiika Pekkarinen <miipekk@ihme.org>2005-07-15 16:42:01 +0000
committerMiika Pekkarinen <miipekk@ihme.org>2005-07-15 16:42:01 +0000
commit34a25a6a3b117582efd49d893bd90e58be7148ca (patch)
tree0668dfe0bb0b28f84869ddede134621631247c33
parentbb0c7751f02842b873e3bc43d4cffe3f85146431 (diff)
downloadrockbox-34a25a6a3b117582efd49d893bd90e58be7148ca.tar.gz
rockbox-34a25a6a3b117582efd49d893bd90e58be7148ca.zip
Fixed a problem that caused playback to stutter when changing tracks
fast. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@7157 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/pcmbuf.c1
-rw-r--r--apps/playback.c24
2 files changed, 13 insertions, 12 deletions
diff --git a/apps/pcmbuf.c b/apps/pcmbuf.c
index eb6c43e284..95a423af6a 100644
--- a/apps/pcmbuf.c
+++ b/apps/pcmbuf.c
@@ -228,6 +228,7 @@ bool pcmbuf_crossfade_init(void)
228{ 228{
229 if (PCMBUF_SIZE - audiobuffer_free < CHUNK_SIZE * 8 || !crossfade_enabled 229 if (PCMBUF_SIZE - audiobuffer_free < CHUNK_SIZE * 8 || !crossfade_enabled
230 || crossfade_active || crossfade_init) { 230 || crossfade_active || crossfade_init) {
231 pcmbuf_flush_audio();
231 return false; 232 return false;
232 } 233 }
233 logf("pcmbuf_crossfade_init"); 234 logf("pcmbuf_crossfade_init");
diff --git a/apps/playback.c b/apps/playback.c
index 7fbfa6bb60..118a72e454 100644
--- a/apps/playback.c
+++ b/apps/playback.c
@@ -131,8 +131,12 @@ int codecbufused;
131static volatile int buf_ridx; 131static volatile int buf_ridx;
132static volatile int buf_widx; 132static volatile int buf_widx;
133 133
134/* Step count to the next unbuffered track. */
134static int last_peek_offset; 135static int last_peek_offset;
135 136
137/* Index of the last buffered track. */
138static int last_index;
139
136/* Track information (count in file buffer, read/write indexes for 140/* Track information (count in file buffer, read/write indexes for
137 track ring structure. */ 141 track ring structure. */
138int track_count; 142int track_count;
@@ -817,6 +821,8 @@ bool audio_load_track(int offset, bool start_play, int peek_offset)
817 if (tracks[track_widx].filesize != 0) 821 if (tracks[track_widx].filesize != 0)
818 return false; 822 return false;
819 823
824 last_index = playlist_get_display_index();
825
820 /* Get track name from current playlist read position. */ 826 /* Get track name from current playlist read position. */
821 logf("Buffering track:%d/%d", track_widx, track_ridx); 827 logf("Buffering track:%d/%d", track_widx, track_ridx);
822 trackname = playlist_peek(peek_offset); 828 trackname = playlist_peek(peek_offset);
@@ -1368,9 +1374,6 @@ static void initiate_track_change(int peek_index)
1368 playlist_next(peek_index); 1374 playlist_next(peek_index);
1369 queue_post(&audio_queue, AUDIO_PLAY, 0); 1375 queue_post(&audio_queue, AUDIO_PLAY, 0);
1370 } 1376 }
1371
1372 else if (!pcmbuf_crossfade_init())
1373 pcmbuf_flush_audio();
1374 1377
1375 codec_track_changed(); 1378 codec_track_changed();
1376} 1379}
@@ -1389,13 +1392,16 @@ void audio_thread(void)
1389 queue_wait_w_tmo(&audio_queue, &ev, 0); 1392 queue_wait_w_tmo(&audio_queue, &ev, 0);
1390 switch (ev.id) { 1393 switch (ev.id) {
1391 case AUDIO_PLAY: 1394 case AUDIO_PLAY:
1395 /* Refuse to start playback if we are already playing
1396 the requested track. */
1397 if (last_index == playlist_get_display_index() && playing)
1398 break ;
1392 logf("starting..."); 1399 logf("starting...");
1393 playing = true; 1400 playing = true;
1394 ci.stop_codec = true; 1401 ci.stop_codec = true;
1395 ci.reload_codec = false; 1402 ci.reload_codec = false;
1396 ci.seek_time = 0; 1403 ci.seek_time = 0;
1397 if (!pcmbuf_crossfade_init() && !pcmbuf_is_crossfade_active()) 1404 pcmbuf_crossfade_init();
1398 pcmbuf_flush_audio();
1399 audio_play_start((int)ev.data); 1405 audio_play_start((int)ev.data);
1400 playlist_update_resume_info(audio_current_track()); 1406 playlist_update_resume_info(audio_current_track());
1401 break ; 1407 break ;
@@ -1570,13 +1576,7 @@ bool audio_has_changed_track(void)
1570void audio_play(int offset) 1576void audio_play(int offset)
1571{ 1577{
1572 logf("audio_play"); 1578 logf("audio_play");
1573 ci.stop_codec = true; 1579 last_index = -1;
1574 if (!pcmbuf_crossfade_init())
1575 pcmbuf_flush_audio();
1576 codec_track_changed();
1577
1578 pcm_play_pause(true);
1579 paused = false;
1580 queue_post(&audio_queue, AUDIO_PLAY, (void *)offset); 1580 queue_post(&audio_queue, AUDIO_PLAY, (void *)offset);
1581} 1581}
1582 1582