From d8a6c0665da7d9b6bd7d5aa2840f86b4a931d0f5 Mon Sep 17 00:00:00 2001 From: Brandon Low Date: Sat, 21 Jan 2006 16:47:36 +0000 Subject: 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 --- apps/pcmbuf.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) (limited to 'apps/pcmbuf.c') diff --git a/apps/pcmbuf.c b/apps/pcmbuf.c index 66dd47eb3d..2d75185f62 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 @@ struct pcmbufdesc 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 @@ int pcmbuf_num_used_buffers(void) 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 @@ void pcmbuf_add_event(void (*event_handler)(void)) 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) -- cgit v1.2.3