mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-12-11 06:05:21 -05:00
Check that PCM is playing/recording *after* getting the current position from the hardware layer.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19435 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
a89837ac61
commit
26bf32c8aa
2 changed files with 13 additions and 12 deletions
|
|
@ -978,8 +978,9 @@ void pcmbuf_beep(unsigned int frequency, size_t duration, int amplitude)
|
|||
/* Get the currently playing chunk at the current position. */
|
||||
bufstart = (int16_t *)pcm_play_dma_get_peak_buffer(&i);
|
||||
|
||||
if (!bufstart)
|
||||
return; /* If above isn't implemented, no beepeth */
|
||||
/* If above isn't implemented or pcm is stopped, no beepeth. */
|
||||
if (!bufstart || !pcm_is_playing())
|
||||
return;
|
||||
|
||||
/* Give 5ms clearance. */
|
||||
bufstart += NATIVE_FREQUENCY * 4 / 200;
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@
|
|||
* pcm_rec_dma_stop
|
||||
* pcm_rec_dma_get_peak_buffer
|
||||
* Data Read/Written within TSP -
|
||||
* pcm_rec_peak_addr (RW)
|
||||
* pcm_rec_peak_addr (R)
|
||||
* pcm_callback_more_ready (R)
|
||||
* pcm_recording (R)
|
||||
*
|
||||
|
|
@ -138,6 +138,8 @@ void pcm_calculate_peaks(int *left, int *right)
|
|||
static unsigned long frame_period = 0;
|
||||
|
||||
long tick = current_tick;
|
||||
int count;
|
||||
const void *addr;
|
||||
|
||||
/* Throttled peak ahead based on calling period */
|
||||
long period = tick - last_peak_tick;
|
||||
|
|
@ -152,18 +154,18 @@ void pcm_calculate_peaks(int *left, int *right)
|
|||
|
||||
last_peak_tick = tick;
|
||||
|
||||
addr = pcm_play_dma_get_peak_buffer(&count);
|
||||
|
||||
if (pcm_playing && !pcm_paused)
|
||||
{
|
||||
const void *addr;
|
||||
int count, framecount;
|
||||
|
||||
addr = pcm_play_dma_get_peak_buffer(&count);
|
||||
int framecount;
|
||||
|
||||
framecount = frame_period*pcm_curr_sampr / HZ;
|
||||
count = MIN(framecount, count);
|
||||
|
||||
if (count > 0)
|
||||
pcm_peak_peeker(addr, count, peaks);
|
||||
/* else keep previous peak values */
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -372,14 +374,11 @@ volatile bool pcm_recording SHAREDBSS_ATTR = false;
|
|||
void pcm_calculate_rec_peaks(int *left, int *right)
|
||||
{
|
||||
static int peaks[2];
|
||||
int count;
|
||||
const void *addr = pcm_rec_dma_get_peak_buffer(&count);
|
||||
|
||||
if (pcm_recording)
|
||||
{
|
||||
const void *addr;
|
||||
int count;
|
||||
|
||||
addr = pcm_rec_dma_get_peak_buffer(&count);
|
||||
|
||||
if (count > 0)
|
||||
{
|
||||
pcm_peak_peeker(addr, count, peaks);
|
||||
|
|
@ -387,6 +386,7 @@ void pcm_calculate_rec_peaks(int *left, int *right)
|
|||
if (addr == pcm_rec_peak_addr)
|
||||
pcm_rec_peak_addr = (int32_t *)addr + count;
|
||||
}
|
||||
/* else keep previous peak values */
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue