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:
Michael Sevakis 2008-12-14 11:42:47 +00:00
parent a89837ac61
commit 26bf32c8aa
2 changed files with 13 additions and 12 deletions

View file

@ -978,8 +978,9 @@ void pcmbuf_beep(unsigned int frequency, size_t duration, int amplitude)
/* Get the currently playing chunk at the current position. */ /* Get the currently playing chunk at the current position. */
bufstart = (int16_t *)pcm_play_dma_get_peak_buffer(&i); bufstart = (int16_t *)pcm_play_dma_get_peak_buffer(&i);
if (!bufstart) /* If above isn't implemented or pcm is stopped, no beepeth. */
return; /* If above isn't implemented, no beepeth */ if (!bufstart || !pcm_is_playing())
return;
/* Give 5ms clearance. */ /* Give 5ms clearance. */
bufstart += NATIVE_FREQUENCY * 4 / 200; bufstart += NATIVE_FREQUENCY * 4 / 200;

View file

@ -65,7 +65,7 @@
* pcm_rec_dma_stop * pcm_rec_dma_stop
* pcm_rec_dma_get_peak_buffer * pcm_rec_dma_get_peak_buffer
* Data Read/Written within TSP - * Data Read/Written within TSP -
* pcm_rec_peak_addr (RW) * pcm_rec_peak_addr (R)
* pcm_callback_more_ready (R) * pcm_callback_more_ready (R)
* pcm_recording (R) * pcm_recording (R)
* *
@ -138,6 +138,8 @@ void pcm_calculate_peaks(int *left, int *right)
static unsigned long frame_period = 0; static unsigned long frame_period = 0;
long tick = current_tick; long tick = current_tick;
int count;
const void *addr;
/* Throttled peak ahead based on calling period */ /* Throttled peak ahead based on calling period */
long period = tick - last_peak_tick; long period = tick - last_peak_tick;
@ -152,18 +154,18 @@ void pcm_calculate_peaks(int *left, int *right)
last_peak_tick = tick; last_peak_tick = tick;
addr = pcm_play_dma_get_peak_buffer(&count);
if (pcm_playing && !pcm_paused) if (pcm_playing && !pcm_paused)
{ {
const void *addr; int framecount;
int count, framecount;
addr = pcm_play_dma_get_peak_buffer(&count);
framecount = frame_period*pcm_curr_sampr / HZ; framecount = frame_period*pcm_curr_sampr / HZ;
count = MIN(framecount, count); count = MIN(framecount, count);
if (count > 0) if (count > 0)
pcm_peak_peeker(addr, count, peaks); pcm_peak_peeker(addr, count, peaks);
/* else keep previous peak values */
} }
else else
{ {
@ -372,14 +374,11 @@ volatile bool pcm_recording SHAREDBSS_ATTR = false;
void pcm_calculate_rec_peaks(int *left, int *right) void pcm_calculate_rec_peaks(int *left, int *right)
{ {
static int peaks[2]; static int peaks[2];
int count;
const void *addr = pcm_rec_dma_get_peak_buffer(&count);
if (pcm_recording) if (pcm_recording)
{ {
const void *addr;
int count;
addr = pcm_rec_dma_get_peak_buffer(&count);
if (count > 0) if (count > 0)
{ {
pcm_peak_peeker(addr, count, peaks); 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) if (addr == pcm_rec_peak_addr)
pcm_rec_peak_addr = (int32_t *)addr + count; pcm_rec_peak_addr = (int32_t *)addr + count;
} }
/* else keep previous peak values */
} }
else else
{ {