The voice PCM buffer has nothing to do with the playback PCM buffer any longer. Allocate it independently from the playback engine's PCM buffer and only when voice is required. Additionally, allocate actual space for the crossfade buffer only when using crossfade. Will save 18.3KB when neither is needed (10.3KB for voice and 8.0KB for crossfade).
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30133 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
d8cb05e31e
commit
a802ebac06
2 changed files with 19 additions and 9 deletions
|
@ -467,22 +467,20 @@ static size_t get_next_required_pcmbuf_size(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Initialize the pcmbuffer the structure looks like this:
|
/* Initialize the pcmbuffer the structure looks like this:
|
||||||
* ...|---------PCMBUF---------|FADEBUF|VOICEBUF|DESCS|... */
|
* ...|---------PCMBUF---------[|FADEBUF]|DESCS|... */
|
||||||
size_t pcmbuf_init(unsigned char *bufend)
|
size_t pcmbuf_init(unsigned char *bufend)
|
||||||
{
|
{
|
||||||
unsigned char *voicebuf;
|
|
||||||
|
|
||||||
pcmbuf_bufend = bufend;
|
pcmbuf_bufend = bufend;
|
||||||
pcmbuf_size = get_next_required_pcmbuf_size();
|
pcmbuf_size = get_next_required_pcmbuf_size();
|
||||||
write_chunk = (struct chunkdesc *)pcmbuf_bufend -
|
write_chunk = (struct chunkdesc *)pcmbuf_bufend -
|
||||||
NUM_CHUNK_DESCS(pcmbuf_size);
|
NUM_CHUNK_DESCS(pcmbuf_size);
|
||||||
voicebuf = (unsigned char *)write_chunk -
|
|
||||||
voicebuf_init((unsigned char *)write_chunk);
|
|
||||||
#ifdef HAVE_CROSSFADE
|
#ifdef HAVE_CROSSFADE
|
||||||
fadebuf = voicebuf - CROSSFADE_BUFSIZE;
|
fadebuf = (unsigned char *)write_chunk -
|
||||||
|
(crossfade_enable_request ? CROSSFADE_BUFSIZE : 0);
|
||||||
pcmbuffer = fadebuf - pcmbuf_size;
|
pcmbuffer = fadebuf - pcmbuf_size;
|
||||||
#else
|
#else
|
||||||
pcmbuffer = voicebuf - pcmbuf_size;
|
pcmbuffer = (unsigned char *)write_chunk - pcmbuf_size;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
init_pcmbuffers();
|
init_pcmbuffers();
|
||||||
|
|
|
@ -738,7 +738,7 @@ static void audio_reset_buffer(void)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Layout audio buffer as follows:
|
* Layout audio buffer as follows:
|
||||||
* [[|TALK]|SCRATCH|BUFFERING|PCM|]
|
* [[|TALK]|SCRATCH|BUFFERING|PCM|[VOICE|]]
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* see audio_get_recording_buffer if this is modified */
|
/* see audio_get_recording_buffer if this is modified */
|
||||||
|
@ -755,6 +755,18 @@ static void audio_reset_buffer(void)
|
||||||
|
|
||||||
ALIGN_BUFFER(filebuf, filebuflen, sizeof (intptr_t));
|
ALIGN_BUFFER(filebuf, filebuflen, sizeof (intptr_t));
|
||||||
|
|
||||||
|
if (talk_voice_required())
|
||||||
|
{
|
||||||
|
/* Need a space for voice PCM output */
|
||||||
|
allocsize = voicebuf_init(filebuf + filebuflen);
|
||||||
|
|
||||||
|
allocsize = ALIGN_UP(allocsize, sizeof (intptr_t));
|
||||||
|
if (allocsize > filebuflen)
|
||||||
|
goto bufpanic;
|
||||||
|
|
||||||
|
filebuflen -= allocsize;
|
||||||
|
}
|
||||||
|
|
||||||
/* Subtract whatever the pcm buffer says it used plus the guard buffer */
|
/* Subtract whatever the pcm buffer says it used plus the guard buffer */
|
||||||
allocsize = pcmbuf_init(filebuf + filebuflen);
|
allocsize = pcmbuf_init(filebuf + filebuflen);
|
||||||
|
|
||||||
|
@ -3475,7 +3487,7 @@ unsigned char * audio_get_buffer(bool talk_buf, size_t *buffer_size)
|
||||||
swap space */
|
swap space */
|
||||||
logf("get buffer: audio");
|
logf("get buffer: audio");
|
||||||
buf = audiobuf + talk_get_bufsize();
|
buf = audiobuf + talk_get_bufsize();
|
||||||
end = audiobufend - pcmbuf_init(audiobufend);
|
end = audiobufend - voicebuf_init(audiobufend);
|
||||||
buffer_state = AUDIOBUF_STATE_VOICED_ONLY;
|
buffer_state = AUDIOBUF_STATE_VOICED_ONLY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue