summaryrefslogtreecommitdiff
path: root/apps/playback.c
diff options
context:
space:
mode:
authorLinus Nielsen Feltzing <linus@haxx.se>2006-08-23 08:21:15 +0000
committerLinus Nielsen Feltzing <linus@haxx.se>2006-08-23 08:21:15 +0000
commit97b56a665c9aafee634ee5ffd6fa86fd2f9c7dd9 (patch)
tree2abad5a833bc3ea81bc1661a0ae78a5e7044f854 /apps/playback.c
parent8a3b6dad94a471f82ae39ed6507074f3c83caf7c (diff)
downloadrockbox-97b56a665c9aafee634ee5ffd6fa86fd2f9c7dd9.tar.gz
rockbox-97b56a665c9aafee634ee5ffd6fa86fd2f9c7dd9.zip
Patch #5844 by Steve Bavin - Fix confused voice file memory allocation
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@10711 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/playback.c')
-rw-r--r--apps/playback.c31
1 files changed, 14 insertions, 17 deletions
diff --git a/apps/playback.c b/apps/playback.c
index ef93177eec..845fb5c7ff 100644
--- a/apps/playback.c
+++ b/apps/playback.c
@@ -481,14 +481,7 @@ static void* get_voice_memory_callback(size_t *size)
481static void* get_codec_memory_callback(size_t *size) 481static void* get_codec_memory_callback(size_t *size)
482{ 482{
483 *size = MALLOC_BUFSIZE; 483 *size = MALLOC_BUFSIZE;
484#if CONFIG_CODEC != SWCODEC 484 return &audiobuf[talk_get_bufsize()];
485 /* MASCODEC cannot play audio and voice simultaneously, so its
486 voice strategy is different - see talk.c for details */
487 if (voice_codec_loaded)
488 return &audiobuf[talk_get_bufsize()];
489 else
490#endif
491 return audiobuf;
492} 485}
493 486
494static void pcmbuf_position_callback(size_t size) ICODE_ATTR; 487static void pcmbuf_position_callback(size_t size) ICODE_ATTR;
@@ -2559,14 +2552,16 @@ static void reset_buffer(void)
2559{ 2552{
2560 size_t offset; 2553 size_t offset;
2561 2554
2562 filebuf = (char *)&audiobuf[MALLOC_BUFSIZE]; 2555 /* Set up file buffer as all space available */
2563 filebuflen = audiobufend - audiobuf - MALLOC_BUFSIZE - GUARD_BUFSIZE - 2556 filebuf = (char *)&audiobuf[talk_get_bufsize()+MALLOC_BUFSIZE];
2557 filebuflen = audiobufend - (unsigned char *) filebuf - GUARD_BUFSIZE -
2564 (pcmbuf_get_bufsize() + get_pcmbuf_descsize() + PCMBUF_MIX_CHUNK * 2); 2558 (pcmbuf_get_bufsize() + get_pcmbuf_descsize() + PCMBUF_MIX_CHUNK * 2);
2565 2559
2560 /* Allow for codec(s) at end of file buffer */
2566 if (talk_voice_required()) 2561 if (talk_voice_required())
2567 { 2562 {
2568 filebuf = &filebuf[talk_get_bufsize()]; 2563 /* Allow 2 codecs at end of file buffer */
2569 filebuflen -= 2*CODEC_IRAM_SIZE + 2*CODEC_SIZE + talk_get_bufsize(); 2564 filebuflen -= 2 * (CODEC_IRAM_SIZE + CODEC_SIZE);
2570 2565
2571#ifndef SIMULATOR 2566#ifndef SIMULATOR
2572 iram_buf[0] = &filebuf[filebuflen]; 2567 iram_buf[0] = &filebuf[filebuflen];
@@ -2577,16 +2572,18 @@ static void reset_buffer(void)
2577 } 2572 }
2578 else 2573 else
2579 { 2574 {
2580 filebuf = &filebuf[talk_get_bufsize()]; 2575 /* Allow for 1 codec at end of file buffer */
2581 filebuflen -= CODEC_IRAM_SIZE + CODEC_SIZE + talk_get_bufsize(); 2576 filebuflen -= CODEC_IRAM_SIZE + CODEC_SIZE;
2582 2577
2583#ifndef SIMULATOR 2578#ifndef SIMULATOR
2584 iram_buf[0] = &filebuf[filebuflen]; 2579 iram_buf[0] = &filebuf[filebuflen];
2580 iram_buf[1] = NULL;
2585#endif 2581#endif
2586 dram_buf[0] = (unsigned char *)&filebuf[filebuflen+CODEC_IRAM_SIZE*2]; 2582 dram_buf[0] = (unsigned char *)&filebuf[filebuflen+CODEC_IRAM_SIZE];
2583 dram_buf[1] = NULL;
2587 } 2584 }
2588 2585
2589 /* Ensure that everything is aligned */ 2586 /* Ensure that file buffer is aligned */
2590 offset = (-(size_t)filebuf) & 3; 2587 offset = (-(size_t)filebuf) & 3;
2591 filebuf += offset; 2588 filebuf += offset;
2592 filebuflen -= offset; 2589 filebuflen -= offset;
@@ -3092,7 +3089,7 @@ static void playback_init(void)
3092#endif 3089#endif
3093 } 3090 }
3094 3091
3095 filebuf = (char *)&audiobuf[MALLOC_BUFSIZE]; 3092 filebuf = (char *)&audiobuf[MALLOC_BUFSIZE]; /* Will be reset by reset_buffer */
3096 3093
3097 audio_set_crossfade(global_settings.crossfade); 3094 audio_set_crossfade(global_settings.crossfade);
3098 3095