summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiika Pekkarinen <miipekk@ihme.org>2005-07-05 15:51:59 +0000
committerMiika Pekkarinen <miipekk@ihme.org>2005-07-05 15:51:59 +0000
commit3e33a0f8ee62dc37e6e028e5dcb39b91e0e0d154 (patch)
tree1bcb2fbcda422a064c9d55df3ac7d517693f72f0
parentd6e79424264147e52f70d9ed34b80e34a9d3c23b (diff)
downloadrockbox-3e33a0f8ee62dc37e6e028e5dcb39b91e0e0d154.tar.gz
rockbox-3e33a0f8ee62dc37e6e028e5dcb39b91e0e0d154.tar.bz2
rockbox-3e33a0f8ee62dc37e6e028e5dcb39b91e0e0d154.zip
More crossfade adjustments. Now crossfade should work shortly even if
the disk was not spinning while a new track was loaded from the disk. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@7028 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/playback.c7
-rw-r--r--firmware/pcm_playback.c23
2 files changed, 18 insertions, 12 deletions
diff --git a/apps/playback.c b/apps/playback.c
index e251a1ee89..8186cf3191 100644
--- a/apps/playback.c
+++ b/apps/playback.c
@@ -614,13 +614,16 @@ void codec_track_changed(void)
queue_post(&audio_queue, AUDIO_TRACK_CHANGED, 0);
}
+/* Give codecs or file buffering the right amount of processing time
+ to prevent pcm audio buffer from going empty. */
void yield_codecs(void)
{
yield();
if (!pcm_is_playing())
sleep(5);
- while (pcm_is_lowdata() && !ci.stop_codec &&
- playing && queue_empty(&audio_queue) && codecbufused > (128*1024))
+ while ((pcm_is_crossfade_active() || pcm_is_lowdata())
+ && !ci.stop_codec && playing && queue_empty(&audio_queue)
+ && codecbufused > (128*1024))
yield();
}
diff --git a/firmware/pcm_playback.c b/firmware/pcm_playback.c
index a58069d5f1..20cd1f2dbd 100644
--- a/firmware/pcm_playback.c
+++ b/firmware/pcm_playback.c
@@ -420,10 +420,10 @@ unsigned int audiobuffer_get_latency(void)
bool pcm_is_lowdata(void)
{
- if (!pcm_is_playing() || pcm_paused)
+ if (!pcm_is_playing() || pcm_paused || crossfade_init || crossfade_active)
return false;
- if (pcmbuf_unplayed_bytes < PCM_WATERMARK || crossfade_active)
+ if (pcmbuf_unplayed_bytes < PCM_WATERMARK)
return true;
return false;
@@ -435,7 +435,7 @@ bool pcm_crossfade_init(void)
|| crossfade_active) {
return false;
}
- logf("crossfading!");
+ logf("pcm_crossfade_init");
pcm_boost(true);
crossfade_mode = CFM_CROSSFADE;
crossfade_init = true;
@@ -478,13 +478,16 @@ void pcm_flush_fillpos(void)
static void crossfade_start(void)
{
+ int bytesleft = pcmbuf_unplayed_bytes;
+
crossfade_init = 0;
- if (PCMBUF_SIZE - audiobuffer_free < CHUNK_SIZE * 4) {
- if (crossfade_mode == CFM_FLUSH)
- pcm_play_stop();
+ if (bytesleft < CHUNK_SIZE * 3) {
+ logf("crossfade rejected");
+ pcm_play_stop();
return ;
}
-
+
+ logf("crossfade_start");
pcm_flush_fillpos();
pcm_boost(true);
crossfade_active = true;
@@ -492,12 +495,12 @@ static void crossfade_start(void)
switch (crossfade_mode) {
case CFM_CROSSFADE:
- crossfade_amount = (PCMBUF_SIZE - audiobuffer_free - (CHUNK_SIZE * 2))/2;
+ crossfade_amount = (bytesleft - (CHUNK_SIZE * 2))/2;
crossfade_rem = crossfade_amount;
break ;
case CFM_FLUSH:
- crossfade_amount = (PCMBUF_SIZE - audiobuffer_free - (CHUNK_SIZE * 2))/2;
+ crossfade_amount = (bytesleft - (CHUNK_SIZE * 2))/2;
crossfade_rem = crossfade_amount;
break ;
}
@@ -586,7 +589,7 @@ void* pcm_request_buffer(long length, long *realsize)
bool pcm_is_crossfade_active(void)
{
- return crossfade_active;
+ return crossfade_active || crossfade_init;
}
void pcm_flush_buffer(long length)