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
This commit is contained in:
Miika Pekkarinen 2005-07-21 15:47:29 +00:00
parent daaa71fc5c
commit ab2163bdf5
3 changed files with 17 additions and 4 deletions

View file

@ -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();
}

View file

@ -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];

View file

@ -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