diff options
author | Miika Pekkarinen <miipekk@ihme.org> | 2005-07-21 15:47:29 +0000 |
---|---|---|
committer | Miika Pekkarinen <miipekk@ihme.org> | 2005-07-21 15:47:29 +0000 |
commit | ab2163bdf5d53f0a771593c454df99e6583afe38 (patch) | |
tree | 6eeec005f1d72f2e95dccd0bd603e95e41610a8c | |
parent | daaa71fc5c4bbb93e1542523647e00df524ca5f2 (diff) |
Fixed the crossfade setting: Resuming stopped playback automatically
when changing values, setting crossfade amount correctly and pcm
drivers should not be re-initialized.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@7214 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | apps/pcmbuf.c | 1 | ||||
-rw-r--r-- | apps/playback.c | 18 | ||||
-rw-r--r-- | apps/settings.c | 2 |
3 files changed, 17 insertions, 4 deletions
diff --git a/apps/pcmbuf.c b/apps/pcmbuf.c index d3f4d15a48..cf6911b606 100644 --- a/apps/pcmbuf.c +++ b/apps/pcmbuf.c @@ -262,7 +262,6 @@ void pcmbuf_init(long bufsize) pcmbuf_size - PCMBUF_GUARD]; guardbuf = &audiobuffer[pcmbuf_size]; pcmbuf_event_handler = NULL; - pcm_init(); pcmbuf_play_stop(); } diff --git a/apps/playback.c b/apps/playback.c index bf8e5bdbaf..88cee8bfd9 100644 --- a/apps/playback.c +++ b/apps/playback.c @@ -1777,10 +1777,16 @@ void audio_set_buffer_margin(int setting) void audio_set_crossfade_amount(int seconds) { long size; + bool was_playing = playing; + int offset; - /* Playback has to be stopped before changing the buffer size. */ - audio_stop_playback(); + /* Store the track resume position */ + if (playing) + offset = cur_ti->id3.offset; + /* Multiply by two to get the real value (0s, 2s, 4s, ...) */ + seconds *= 2; + /* Buffer has to be at least 2s long. */ seconds += 2; logf("buf len: %d", seconds); @@ -1788,6 +1794,9 @@ void audio_set_crossfade_amount(int seconds) if (pcmbuf_get_bufsize() == size) return ; + /* Playback has to be stopped before changing the buffer size. */ + audio_stop_playback(); + /* Re-initialize audio system. */ pcmbuf_init(size); pcmbuf_crossfade_enable(seconds > 2); @@ -1795,6 +1804,10 @@ void audio_set_crossfade_amount(int seconds) - PCMBUF_GUARD - MALLOC_BUFSIZE - GUARD_BUFSIZE; logf("abuf:%dB", pcmbuf_get_bufsize()); logf("fbuf:%dB", codecbuflen); + + /* Restart playback. */ + if (was_playing) + audio_play(offset); } void mpeg_id3_options(bool _v1first) @@ -1821,6 +1834,7 @@ void test_unbuffer_event(struct mp3entry *id3, bool last_track) void audio_init(void) { logf("audio api init"); + pcm_init(); codecbufused = 0; filling = false; codecbuf = &audiobuf[MALLOC_BUFSIZE]; diff --git a/apps/settings.c b/apps/settings.c index e9f45de130..d374f00ff2 100644 --- a/apps/settings.c +++ b/apps/settings.c @@ -851,7 +851,7 @@ void settings_apply(void) } #if CONFIG_HWCODEC == MASNONE - audio_set_crossfade_amount(global_settings.crossfade*2); + audio_set_crossfade_amount(global_settings.crossfade); #endif #ifdef HAVE_SPDIF_POWER |