Index: apps/pcmbuf.c =================================================================== --- apps/pcmbuf.c (revision 19401) +++ apps/pcmbuf.c (working copy) @@ -972,10 +972,18 @@ /* Find the insertion point and set bufstart to the start of it */ if (mix) { - /* Get the next chunk */ - char *pcmbuf_mix_buf = pcmbuf_read->link->addr; - /* Give 1/8s clearance. */ - bufstart = (int16_t *)&pcmbuf_mix_buf[NATIVE_FREQUENCY * 4 / 8]; + /* Get the currently playing chunk */ + bufstart = (int16_t*)pcm_play_dma_get_peak_buffer(&i); + + if (!bufstart) + return; /* If this function isn't implemented, no beepeth */ + + /* Give 5ms clearance. */ + bufstart += NATIVE_FREQUENCY * 4 / 200; + /* NOTE: On some targets using hardware DMA, cache range flushing may + * be required or the writes may not be picked up by the controller. + * An incremental flush should be done periodically during the mixdown. + */ } else { @@ -1000,11 +1008,15 @@ phase += step; } + pcm_play_lock(); + /* Kick off playback if required */ if (!pcm_is_playing()) { pcm_play_data(NULL, (unsigned char *)bufstart, samples * 4); } + + pcm_play_unlock(); } #endif /* HAVE_HARDWARE_BEEP */