summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
authorLinus Nielsen Feltzing <linus@haxx.se>2005-06-09 09:47:00 +0000
committerLinus Nielsen Feltzing <linus@haxx.se>2005-06-09 09:47:00 +0000
commit6271b2b9104e060f8e25c780f3cbb010cbcba827 (patch)
tree4c52d92b49946083e5a08c5c20e202dd767cda03 /firmware
parent614f0a333a6263def7e6cd053abfc222dae2ced5 (diff)
downloadrockbox-6271b2b9104e060f8e25c780f3cbb010cbcba827.tar.gz
rockbox-6271b2b9104e060f8e25c780f3cbb010cbcba827.zip
Added Crossfade setting for iRiver
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@6636 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware')
-rw-r--r--firmware/export/pcm_playback.h1
-rw-r--r--firmware/pcm_playback.c33
2 files changed, 21 insertions, 13 deletions
diff --git a/firmware/export/pcm_playback.h b/firmware/export/pcm_playback.h
index d101c823ba..0f2de83224 100644
--- a/firmware/export/pcm_playback.h
+++ b/firmware/export/pcm_playback.h
@@ -45,5 +45,6 @@ bool pcm_is_lowdata(void);
45void pcm_crossfade_start(void); 45void pcm_crossfade_start(void);
46unsigned int audiobuffer_get_latency(void); 46unsigned int audiobuffer_get_latency(void);
47bool audiobuffer_insert(char *buf, size_t length); 47bool audiobuffer_insert(char *buf, size_t length);
48void pcm_crossfade_enable(bool on_off);
48 49
49#endif 50#endif
diff --git a/firmware/pcm_playback.c b/firmware/pcm_playback.c
index ab4f0c0375..e5d6f4218b 100644
--- a/firmware/pcm_playback.c
+++ b/firmware/pcm_playback.c
@@ -56,6 +56,7 @@ static volatile size_t audiobuffer_free;
56static size_t audiobuffer_fillpos; 56static size_t audiobuffer_fillpos;
57static bool boost_mode; 57static bool boost_mode;
58 58
59static bool crossfade_enabled;
59static bool crossfade_active; 60static bool crossfade_active;
60static int crossfade_pos; 61static int crossfade_pos;
61static int crossfade_amount; 62static int crossfade_amount;
@@ -432,18 +433,7 @@ bool audiobuffer_insert(char *buf, size_t length)
432 } 433 }
433 434
434 while (length > 0) { 435 while (length > 0) {
435 if (!crossfade_active) { 436 if (crossfade_enabled && crossfade_active) {
436 copy_n = MIN(length, PCMBUF_SIZE - audiobuffer_pos -
437 audiobuffer_fillpos);
438 copy_n = MIN(CHUNK_SIZE, copy_n);
439
440 memcpy(&audiobuffer[audiobuffer_pos+audiobuffer_fillpos],
441 buf, copy_n);
442 buf += copy_n;
443 audiobuffer_free -= copy_n;
444 length -= copy_n;
445
446 } else {
447 copy_n = MIN(length, PCMBUF_SIZE - (unsigned int)crossfade_pos); 437 copy_n = MIN(length, PCMBUF_SIZE - (unsigned int)crossfade_pos);
448 438
449 crossfade((short *)&audiobuffer[crossfade_pos], 439 crossfade((short *)&audiobuffer[crossfade_pos],
@@ -453,7 +443,17 @@ bool audiobuffer_insert(char *buf, size_t length)
453 crossfade_pos += copy_n; 443 crossfade_pos += copy_n;
454 if (crossfade_pos >= PCMBUF_SIZE) 444 if (crossfade_pos >= PCMBUF_SIZE)
455 crossfade_pos -= PCMBUF_SIZE; 445 crossfade_pos -= PCMBUF_SIZE;
456 continue ; 446 continue ;
447 } else {
448 copy_n = MIN(length, PCMBUF_SIZE - audiobuffer_pos -
449 audiobuffer_fillpos);
450 copy_n = MIN(CHUNK_SIZE, copy_n);
451
452 memcpy(&audiobuffer[audiobuffer_pos+audiobuffer_fillpos],
453 buf, copy_n);
454 buf += copy_n;
455 audiobuffer_free -= copy_n;
456 length -= copy_n;
457 } 457 }
458 458
459 /* Pre-buffer to meet CHUNK_SIZE requirement */ 459 /* Pre-buffer to meet CHUNK_SIZE requirement */
@@ -501,6 +501,13 @@ void pcm_play_init(void)
501 memset(&audiobuffer[0], 0, audiobuffer_pos); 501 memset(&audiobuffer[0], 0, audiobuffer_pos);
502 pcm_play_add_chunk(&audiobuffer[0], audiobuffer_pos, NULL); 502 pcm_play_add_chunk(&audiobuffer[0], audiobuffer_pos, NULL);
503 pcm_play_start(); 503 pcm_play_start();
504
505 crossfade_enabled = false;
506}
507
508void pcm_crossfade_enable(bool on_off)
509{
510 crossfade_enabled = on_off;
504} 511}
505 512
506void pcm_play_start(void) 513void pcm_play_start(void)