Improve performance by putting more of the code and variables that are called by the DMA0 interrupt into IRAM (3% boost improvement on my test track).
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@8404 a1c6a512-1295-4272-9138-f99709370657
diff --git a/apps/pcmbuf.c b/apps/pcmbuf.c
index 66dd47e..2d75185 100644
--- a/apps/pcmbuf.c
+++ b/apps/pcmbuf.c
@@ -46,8 +46,8 @@
static long pcmbuf_size = 0; /* Size of the PCM buffer. */
static char *audiobuffer;
static long audiobuffer_pos; /* Current audio buffer write index. */
-long audiobuffer_free; /* Amount of bytes left in the buffer. */
-static long audiobuffer_fillpos; /* Amount audiobuffer_pos will be increased. */
+long audiobuffer_free IDATA_ATTR; /* Amount of bytes left in the buffer. */
+static long audiobuffer_fillpos; /* Amount audiobuffer_pos will be increased.*/
static char *guardbuf;
static void (*pcmbuf_event_handler)(void);
@@ -81,11 +81,11 @@
int size;
/* Call this when the buffer has been played */
void (*callback)(void);
-} pcmbuffers[NUM_PCM_BUFFERS];
+} pcmbuffers[NUM_PCM_BUFFERS] IDATA_ATTR;
volatile int pcmbuf_read_index;
volatile int pcmbuf_write_index;
-int pcmbuf_unplayed_bytes;
+int pcmbuf_unplayed_bytes IDATA_ATTR;
int pcmbuf_mix_used_bytes;
int pcmbuf_watermark;
void (*pcmbuf_watermark_event)(int bytes_left);
@@ -121,6 +121,7 @@
return (pcmbuf_write_index - pcmbuf_read_index) & NUM_PCM_BUFFERS_MASK;
}
+static void pcmbuf_callback(unsigned char** start, long* size) ICODE_ATTR;
static void pcmbuf_callback(unsigned char** start, long* size)
{
struct pcmbufdesc *desc = &pcmbuffers[pcmbuf_read_index];
@@ -206,14 +207,10 @@
unsigned int pcmbuf_get_latency(void)
{
- int latency;
+ int latency = (pcmbuf_unplayed_bytes + pcm_get_bytes_waiting())
+ * 1000 / 4 / 44100;
- latency = (pcmbuf_unplayed_bytes + pcm_get_bytes_waiting())
- * 1000 / 4 / 44100;
- if (latency < 0)
- latency = 0;
-
- return latency;
+ return latency<0?0:latency;
}
bool pcmbuf_is_lowdata(void)
diff --git a/firmware/pcm_playback.c b/firmware/pcm_playback.c
index fe71fa3..36c6ab6 100644
--- a/firmware/pcm_playback.c
+++ b/firmware/pcm_playback.c
@@ -59,8 +59,8 @@
static bool pcm_paused;
static int pcm_freq = 0x6; /* 44.1 is default */
-static unsigned char *next_start;
-static long next_size;
+static unsigned char *next_start IDATA_ATTR;
+static long next_size IDATA_ATTR;
/* Set up the DMA transfer that kicks in when the audio FIFO gets empty */
static void dma_start(const void *addr, long size)
@@ -193,7 +193,7 @@
}
/* the registered callback function to ask for more mp3 data */
-static void (*callback_for_more)(unsigned char**, long*) = NULL;
+static void (*callback_for_more)(unsigned char**, long*) IDATA_ATTR = NULL;
void pcm_play_data(void (*get_more)(unsigned char** start, long* size))
{