diff options
| author | Miika Pekkarinen <miipekk@ihme.org> | 2005-07-19 19:57:23 +0000 |
|---|---|---|
| committer | Miika Pekkarinen <miipekk@ihme.org> | 2005-07-19 19:57:23 +0000 |
| commit | d83b659fa7206b150779274635a013def1ed850e (patch) | |
| tree | c66e2f1ed7615c22b8492bdd4cdc4885f3bd65ba | |
| parent | 30b8378b68716dcc7ac6c900e4831f2f1991fddd (diff) | |
| download | rockbox-d83b659fa7206b150779274635a013def1ed850e.zip rockbox-d83b659fa7206b150779274635a013def1ed850e.tar.gz rockbox-d83b659fa7206b150779274635a013def1ed850e.tar.bz2 rockbox-d83b659fa7206b150779274635a013def1ed850e.tar.xz | |
Fixed track changing problems.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@7201 a1c6a512-1295-4272-9138-f99709370657
| -rw-r--r-- | apps/pcmbuf.c | 31 | ||||
| -rw-r--r-- | apps/playback.c | 15 |
2 files changed, 21 insertions, 25 deletions
diff --git a/apps/pcmbuf.c b/apps/pcmbuf.c index 95a423a..bcf971d 100644 --- a/apps/pcmbuf.c +++ b/apps/pcmbuf.c @@ -85,7 +85,7 @@ volatile int pcmbuf_write_index; int pcmbuf_unplayed_bytes; int pcmbuf_watermark; void (*pcmbuf_watermark_event)(int bytes_left); -static int last_chunksize; +//static int last_chunksize; static void pcmbuf_boost(bool state) { @@ -110,11 +110,6 @@ int pcmbuf_num_used_buffers(void) static void pcmbuf_callback(unsigned char** start, long* size) { struct pcmbufdesc *desc = &pcmbuffers[pcmbuf_read_index]; - int sz; - - pcmbuf_unplayed_bytes -= last_chunksize; - audiobuffer_free += last_chunksize; - if(desc->size == 0) { @@ -129,17 +124,15 @@ static void pcmbuf_callback(unsigned char** start, long* size) if(pcmbuf_num_used_buffers()) { - /* Play max 64K at a time */ - //sz = MIN(desc->size, 32768); - sz = desc->size; + pcmbuf_unplayed_bytes -= desc->size; + audiobuffer_free += desc->size; + *start = desc->addr; - *size = sz; + *size = desc->size; /* Update the buffer descriptor */ - desc->size -= sz; - desc->addr += sz; - - last_chunksize = sz; + desc->addr += desc->size; + desc->size = 0; } else { @@ -243,7 +236,7 @@ bool pcmbuf_crossfade_init(void) void pcmbuf_play_stop(void) { pcm_play_stop(); - last_chunksize = 0; + //last_chunksize = 0; pcmbuf_unplayed_bytes = 0; pcmbuf_read_index = 0; pcmbuf_write_index = 0; @@ -278,6 +271,7 @@ void pcmbuf_flush_audio(void) return ; } + pcmbuf_boost(true); crossfade_mode = CFM_FLUSH; crossfade_init = true; } @@ -296,7 +290,8 @@ void pcmbuf_flush_fillpos(void) /* This is a fatal error situation that should never happen. */ if (!pcm_is_playing()) { logf("pcm_flush_fillpos error"); - break ; + pcm_play_data(pcmbuf_callback); + return ; } } pcmbuf_event_handler = NULL; @@ -320,7 +315,7 @@ static void crossfade_start(void) } logf("crossfade_start"); - pcmbuf_flush_fillpos(); + audiobuffer_fillpos = 0; pcmbuf_boost(true); crossfade_active = true; crossfade_pos = audiobuffer_pos; @@ -384,7 +379,7 @@ static bool prepare_insert(long length) pcmbuf_boost(false); return false; } - + if (!pcm_is_playing()) { pcmbuf_boost(true); crossfade_active = false; diff --git a/apps/playback.c b/apps/playback.c index 0b67615..63bf4db 100644 --- a/apps/playback.c +++ b/apps/playback.c @@ -392,7 +392,7 @@ void codec_advance_buffer_callback(long amount) if (amount > cur_ti->available + cur_ti->filerem) amount = cur_ti->available + cur_ti->filerem; - if (amount > cur_ti->available) { + if (amount > cur_ti->available && !filling) { if (!rebuffer_and_seek(ci.curpos + amount)) ci.stop_codec = true; return ; @@ -1346,16 +1346,16 @@ static void initiate_track_change(int peek_index) if (!playlist_check(peek_index)) return ; - new_track = peek_index; - ci.reload_codec = true; - /* Detect if disk is spinning.. */ if (filling) { ci.stop_codec = true; playlist_next(peek_index); queue_post(&audio_queue, AUDIO_PLAY, 0); } else { - pcmbuf_crossfade_init(); + new_track = peek_index; + ci.reload_codec = true; + if (!pcmbuf_is_crossfade_enabled()) + pcmbuf_flush_audio(); } codec_track_changed(); @@ -1384,8 +1384,9 @@ void audio_thread(void) ci.stop_codec = true; ci.reload_codec = false; ci.seek_time = 0; - if (!pcmbuf_is_crossfade_active()) - pcmbuf_crossfade_init(); + pcmbuf_crossfade_init(); + while (codec_loaded) + yield(); audio_play_start((int)ev.data); playlist_update_resume_info(audio_current_track()); break ; |