diff --git a/apps/pcmbuf.c b/apps/pcmbuf.c index ae8f0c2c33..eb6c43e284 100644 --- a/apps/pcmbuf.c +++ b/apps/pcmbuf.c @@ -312,7 +312,7 @@ static void crossfade_start(void) int bytesleft = pcmbuf_unplayed_bytes; crossfade_init = 0; - if (bytesleft < CHUNK_SIZE * 3) { + if (bytesleft < CHUNK_SIZE * 4) { logf("crossfade rejected"); pcmbuf_play_stop(); return ; @@ -399,7 +399,10 @@ static bool prepare_insert(long length) void* pcmbuf_request_buffer(long length, long *realsize) { void *ptr = NULL; - + + if (crossfade_init) + crossfade_start(); + while (audiobuffer_free < length + audiobuffer_fillpos + CHUNK_SIZE && !crossfade_active) { pcmbuf_boost(false); diff --git a/apps/playback.c b/apps/playback.c index 0e20d97fb4..7fbfa6bb60 100644 --- a/apps/playback.c +++ b/apps/playback.c @@ -1192,16 +1192,18 @@ static void audio_stop_playback(void) { paused = false; playing = false; + filling = false; ci.stop_codec = true; if (current_fd >= 0) { close(current_fd); current_fd = -1; } + while (codec_loaded) + yield(); pcmbuf_play_stop(); pcm_play_pause(true); track_count = 0; audio_clear_track_entries(); - filling = false; } /* Request the next track with new codec. */