summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2008-12-14 11:42:47 +0000
committerMichael Sevakis <jethead71@rockbox.org>2008-12-14 11:42:47 +0000
commit26bf32c8aacb115528fafae552d576227b08ea7a (patch)
tree64e0a4fba6576ebf0b4c23882351a1fb70710929
parenta89837ac61c75e335cbb1d722872bb8ae9cbc9b8 (diff)
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
-rw-r--r--apps/pcmbuf.c5
-rw-r--r--firmware/pcm.c20
2 files changed, 13 insertions, 12 deletions
diff --git a/apps/pcmbuf.c b/apps/pcmbuf.c
index b22fd789a6..095b5209eb 100644
--- a/apps/pcmbuf.c
+++ b/apps/pcmbuf.c
@@ -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;
diff --git a/firmware/pcm.c b/firmware/pcm.c
index 19bba4143e..38204f883b 100644
--- a/firmware/pcm.c
+++ b/firmware/pcm.c
@@ -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
{