summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/pcmbuf.c12
-rw-r--r--apps/playback.c16
2 files changed, 19 insertions, 9 deletions
diff --git a/apps/pcmbuf.c b/apps/pcmbuf.c
index ca17437534..946eb16021 100644
--- a/apps/pcmbuf.c
+++ b/apps/pcmbuf.c
@@ -467,22 +467,20 @@ static size_t get_next_required_pcmbuf_size(void)
467} 467}
468 468
469/* Initialize the pcmbuffer the structure looks like this: 469/* Initialize the pcmbuffer the structure looks like this:
470 * ...|---------PCMBUF---------|FADEBUF|VOICEBUF|DESCS|... */ 470 * ...|---------PCMBUF---------[|FADEBUF]|DESCS|... */
471size_t pcmbuf_init(unsigned char *bufend) 471size_t pcmbuf_init(unsigned char *bufend)
472{ 472{
473 unsigned char *voicebuf;
474
475 pcmbuf_bufend = bufend; 473 pcmbuf_bufend = bufend;
476 pcmbuf_size = get_next_required_pcmbuf_size(); 474 pcmbuf_size = get_next_required_pcmbuf_size();
477 write_chunk = (struct chunkdesc *)pcmbuf_bufend - 475 write_chunk = (struct chunkdesc *)pcmbuf_bufend -
478 NUM_CHUNK_DESCS(pcmbuf_size); 476 NUM_CHUNK_DESCS(pcmbuf_size);
479 voicebuf = (unsigned char *)write_chunk - 477
480 voicebuf_init((unsigned char *)write_chunk);
481#ifdef HAVE_CROSSFADE 478#ifdef HAVE_CROSSFADE
482 fadebuf = voicebuf - CROSSFADE_BUFSIZE; 479 fadebuf = (unsigned char *)write_chunk -
480 (crossfade_enable_request ? CROSSFADE_BUFSIZE : 0);
483 pcmbuffer = fadebuf - pcmbuf_size; 481 pcmbuffer = fadebuf - pcmbuf_size;
484#else 482#else
485 pcmbuffer = voicebuf - pcmbuf_size; 483 pcmbuffer = (unsigned char *)write_chunk - pcmbuf_size;
486#endif 484#endif
487 485
488 init_pcmbuffers(); 486 init_pcmbuffers();
diff --git a/apps/playback.c b/apps/playback.c
index c74c606016..fe9bd579d4 100644
--- a/apps/playback.c
+++ b/apps/playback.c
@@ -738,7 +738,7 @@ static void audio_reset_buffer(void)
738{ 738{
739 /* 739 /*
740 * Layout audio buffer as follows: 740 * Layout audio buffer as follows:
741 * [[|TALK]|SCRATCH|BUFFERING|PCM|] 741 * [[|TALK]|SCRATCH|BUFFERING|PCM|[VOICE|]]
742 */ 742 */
743 743
744 /* see audio_get_recording_buffer if this is modified */ 744 /* see audio_get_recording_buffer if this is modified */
@@ -755,6 +755,18 @@ static void audio_reset_buffer(void)
755 755
756 ALIGN_BUFFER(filebuf, filebuflen, sizeof (intptr_t)); 756 ALIGN_BUFFER(filebuf, filebuflen, sizeof (intptr_t));
757 757
758 if (talk_voice_required())
759 {
760 /* Need a space for voice PCM output */
761 allocsize = voicebuf_init(filebuf + filebuflen);
762
763 allocsize = ALIGN_UP(allocsize, sizeof (intptr_t));
764 if (allocsize > filebuflen)
765 goto bufpanic;
766
767 filebuflen -= allocsize;
768 }
769
758 /* Subtract whatever the pcm buffer says it used plus the guard buffer */ 770 /* Subtract whatever the pcm buffer says it used plus the guard buffer */
759 allocsize = pcmbuf_init(filebuf + filebuflen); 771 allocsize = pcmbuf_init(filebuf + filebuflen);
760 772
@@ -3475,7 +3487,7 @@ unsigned char * audio_get_buffer(bool talk_buf, size_t *buffer_size)
3475 swap space */ 3487 swap space */
3476 logf("get buffer: audio"); 3488 logf("get buffer: audio");
3477 buf = audiobuf + talk_get_bufsize(); 3489 buf = audiobuf + talk_get_bufsize();
3478 end = audiobufend - pcmbuf_init(audiobufend); 3490 end = audiobufend - voicebuf_init(audiobufend);
3479 buffer_state = AUDIOBUF_STATE_VOICED_ONLY; 3491 buffer_state = AUDIOBUF_STATE_VOICED_ONLY;
3480 } 3492 }
3481 3493