diff options
-rw-r--r-- | apps/playback.c | 23 | ||||
-rw-r--r-- | apps/settings_menu.c | 8 | ||||
-rw-r--r-- | apps/talk.c | 17 | ||||
-rw-r--r-- | apps/talk.h | 1 |
4 files changed, 37 insertions, 12 deletions
diff --git a/apps/playback.c b/apps/playback.c index 890a2d7d1b..ef93177eec 100644 --- a/apps/playback.c +++ b/apps/playback.c | |||
@@ -481,9 +481,13 @@ static void* get_voice_memory_callback(size_t *size) | |||
481 | static void* get_codec_memory_callback(size_t *size) | 481 | static void* get_codec_memory_callback(size_t *size) |
482 | { | 482 | { |
483 | *size = MALLOC_BUFSIZE; | 483 | *size = MALLOC_BUFSIZE; |
484 | #if CONFIG_CODEC != SWCODEC | ||
485 | /* MASCODEC cannot play audio and voice simultaneously, so its | ||
486 | voice strategy is different - see talk.c for details */ | ||
484 | if (voice_codec_loaded) | 487 | if (voice_codec_loaded) |
485 | return &audiobuf[talk_get_bufsize()]; | 488 | return &audiobuf[talk_get_bufsize()]; |
486 | else | 489 | else |
490 | #endif | ||
487 | return audiobuf; | 491 | return audiobuf; |
488 | } | 492 | } |
489 | 493 | ||
@@ -2559,7 +2563,7 @@ static void reset_buffer(void) | |||
2559 | filebuflen = audiobufend - audiobuf - MALLOC_BUFSIZE - GUARD_BUFSIZE - | 2563 | filebuflen = audiobufend - audiobuf - MALLOC_BUFSIZE - GUARD_BUFSIZE - |
2560 | (pcmbuf_get_bufsize() + get_pcmbuf_descsize() + PCMBUF_MIX_CHUNK * 2); | 2564 | (pcmbuf_get_bufsize() + get_pcmbuf_descsize() + PCMBUF_MIX_CHUNK * 2); |
2561 | 2565 | ||
2562 | if (talk_get_bufsize()) | 2566 | if (talk_voice_required()) |
2563 | { | 2567 | { |
2564 | filebuf = &filebuf[talk_get_bufsize()]; | 2568 | filebuf = &filebuf[talk_get_bufsize()]; |
2565 | filebuflen -= 2*CODEC_IRAM_SIZE + 2*CODEC_SIZE + talk_get_bufsize(); | 2569 | filebuflen -= 2*CODEC_IRAM_SIZE + 2*CODEC_SIZE + talk_get_bufsize(); |
@@ -2569,8 +2573,17 @@ static void reset_buffer(void) | |||
2569 | iram_buf[1] = &filebuf[filebuflen+CODEC_IRAM_SIZE]; | 2573 | iram_buf[1] = &filebuf[filebuflen+CODEC_IRAM_SIZE]; |
2570 | #endif | 2574 | #endif |
2571 | dram_buf[0] = (unsigned char *)&filebuf[filebuflen+CODEC_IRAM_SIZE*2]; | 2575 | dram_buf[0] = (unsigned char *)&filebuf[filebuflen+CODEC_IRAM_SIZE*2]; |
2572 | dram_buf[1] = | 2576 | dram_buf[1] = (unsigned char *)&filebuf[filebuflen+CODEC_IRAM_SIZE*2+CODEC_SIZE]; |
2573 | (unsigned char *)&filebuf[filebuflen+CODEC_IRAM_SIZE*2+CODEC_SIZE]; | 2577 | } |
2578 | else | ||
2579 | { | ||
2580 | filebuf = &filebuf[talk_get_bufsize()]; | ||
2581 | filebuflen -= CODEC_IRAM_SIZE + CODEC_SIZE + talk_get_bufsize(); | ||
2582 | |||
2583 | #ifndef SIMULATOR | ||
2584 | iram_buf[0] = &filebuf[filebuflen]; | ||
2585 | #endif | ||
2586 | dram_buf[0] = (unsigned char *)&filebuf[filebuflen+CODEC_IRAM_SIZE*2]; | ||
2574 | } | 2587 | } |
2575 | 2588 | ||
2576 | /* Ensure that everything is aligned */ | 2589 | /* Ensure that everything is aligned */ |
@@ -2616,8 +2629,8 @@ void voice_init(void) | |||
2616 | voice_codec_loaded = false; | 2629 | voice_codec_loaded = false; |
2617 | } | 2630 | } |
2618 | 2631 | ||
2619 | if (!talk_get_bufsize()) | 2632 | if (!talk_voice_required()) |
2620 | return ; | 2633 | return; |
2621 | 2634 | ||
2622 | logf("Starting voice codec"); | 2635 | logf("Starting voice codec"); |
2623 | queue_init(&voice_codec_queue); | 2636 | queue_init(&voice_codec_queue); |
diff --git a/apps/settings_menu.c b/apps/settings_menu.c index 48e8c1dda5..448411593a 100644 --- a/apps/settings_menu.c +++ b/apps/settings_menu.c | |||
@@ -1264,16 +1264,20 @@ static const struct opt_items voice_names[] = { | |||
1264 | 1264 | ||
1265 | static bool voice_dirs(void) | 1265 | static bool voice_dirs(void) |
1266 | { | 1266 | { |
1267 | return set_option( str(LANG_VOICE_DIR), | 1267 | bool ret = set_option( str(LANG_VOICE_DIR), |
1268 | &global_settings.talk_dir, INT, voice_names, 4, NULL); | 1268 | &global_settings.talk_dir, INT, voice_names, 4, NULL); |
1269 | audio_set_crossfade(global_settings.crossfade); | ||
1270 | return ret; | ||
1269 | } | 1271 | } |
1270 | 1272 | ||
1271 | static bool voice_files(void) | 1273 | static bool voice_files(void) |
1272 | { | 1274 | { |
1273 | int oldval = global_settings.talk_file; | 1275 | int oldval = global_settings.talk_file; |
1274 | bool ret; | 1276 | bool ret; |
1277 | |||
1275 | ret = set_option( str(LANG_VOICE_FILE), | 1278 | ret = set_option( str(LANG_VOICE_FILE), |
1276 | &global_settings.talk_file, INT, voice_names, 4, NULL); | 1279 | &global_settings.talk_file, INT, voice_names, 4, NULL); |
1280 | audio_set_crossfade(global_settings.crossfade); | ||
1277 | if (oldval != 3 && global_settings.talk_file == 3) | 1281 | if (oldval != 3 && global_settings.talk_file == 3) |
1278 | { /* force reload if newly talking thumbnails, | 1282 | { /* force reload if newly talking thumbnails, |
1279 | because the clip presence is cached only if enabled */ | 1283 | because the clip presence is cached only if enabled */ |
@@ -1462,9 +1466,7 @@ static bool crossfade(void) | |||
1462 | 1466 | ||
1463 | ret=set_option( str(LANG_CROSSFADE_ENABLE), | 1467 | ret=set_option( str(LANG_CROSSFADE_ENABLE), |
1464 | &global_settings.crossfade, INT, names, 4, NULL); | 1468 | &global_settings.crossfade, INT, names, 4, NULL); |
1465 | |||
1466 | audio_set_crossfade(global_settings.crossfade); | 1469 | audio_set_crossfade(global_settings.crossfade); |
1467 | |||
1468 | return ret; | 1470 | return ret; |
1469 | } | 1471 | } |
1470 | 1472 | ||
diff --git a/apps/talk.c b/apps/talk.c index 736c68c7b4..8f507eb700 100644 --- a/apps/talk.c +++ b/apps/talk.c | |||
@@ -146,10 +146,6 @@ static int open_voicefile(void) | |||
146 | return open(buf, O_RDONLY); | 146 | return open(buf, O_RDONLY); |
147 | } | 147 | } |
148 | 148 | ||
149 | int talk_get_bufsize(void) | ||
150 | { | ||
151 | return voicefile_size; | ||
152 | } | ||
153 | 149 | ||
154 | /* load the voice file into the mp3 buffer */ | 150 | /* load the voice file into the mp3 buffer */ |
155 | static void load_voicefile(void) | 151 | static void load_voicefile(void) |
@@ -532,6 +528,19 @@ void talk_init(void) | |||
532 | } | 528 | } |
533 | } | 529 | } |
534 | 530 | ||
531 | /* return if a voice codec is required or not */ | ||
532 | bool talk_voice_required(void) | ||
533 | { | ||
534 | return (voicefile_size != 0) | ||
535 | || (global_settings.talk_dir == 3) | ||
536 | || (global_settings.talk_file == 3); | ||
537 | } | ||
538 | |||
539 | /* return size of voice file */ | ||
540 | int talk_get_bufsize(void) | ||
541 | { | ||
542 | return voicefile_size; | ||
543 | } | ||
535 | 544 | ||
536 | /* somebody else claims the mp3 buffer, e.g. for regular play/record */ | 545 | /* somebody else claims the mp3 buffer, e.g. for regular play/record */ |
537 | int talk_buffer_steal(void) | 546 | int talk_buffer_steal(void) |
diff --git a/apps/talk.h b/apps/talk.h index 58ab0ef37a..0dc6996f39 100644 --- a/apps/talk.h +++ b/apps/talk.h | |||
@@ -58,6 +58,7 @@ extern const char* const dir_thumbnail_name; /* "_dirname.talk" */ | |||
58 | extern const char* const file_thumbnail_ext; /* ".talk" for file voicing */ | 58 | extern const char* const file_thumbnail_ext; /* ".talk" for file voicing */ |
59 | 59 | ||
60 | void talk_init(void); | 60 | void talk_init(void); |
61 | bool talk_voice_required(void); /* returns true if voice codec required */ | ||
61 | int talk_get_bufsize(void); /* get the loaded voice file size */ | 62 | int talk_get_bufsize(void); /* get the loaded voice file size */ |
62 | int talk_buffer_steal(void); /* claim the mp3 buffer e.g. for play/record */ | 63 | int talk_buffer_steal(void); /* claim the mp3 buffer e.g. for play/record */ |
63 | int talk_id(long id, bool enqueue); /* play a voice ID from voicefont */ | 64 | int talk_id(long id, bool enqueue); /* play a voice ID from voicefont */ |