summaryrefslogtreecommitdiff
path: root/apps/plugins/pdbox
diff options
context:
space:
mode:
authorWincent Balin <wincent@rockbox.org>2010-06-01 20:37:16 +0000
committerWincent Balin <wincent@rockbox.org>2010-06-01 20:37:16 +0000
commitf52c9aae3a04ae4c767c2da1d788421686805fea (patch)
tree2050e9bcdb6797c16f4acbd2567686a07dab9e1b /apps/plugins/pdbox
parent279969618d28e23ac83b6e81c7b7bbf1adaf5b74 (diff)
downloadrockbox-f52c9aae3a04ae4c767c2da1d788421686805fea.tar.gz
rockbox-f52c9aae3a04ae4c767c2da1d788421686805fea.zip
pdbox: Code cleanup, optimizations.
* Reverted minimal working memory to 4 MB * Reverted size of a single audio buffer * Optimized sound output loop git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26454 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins/pdbox')
-rw-r--r--apps/plugins/pdbox/PDa/src/s_audio_rockbox.c73
-rw-r--r--apps/plugins/pdbox/pdbox.h6
2 files changed, 42 insertions, 37 deletions
diff --git a/apps/plugins/pdbox/PDa/src/s_audio_rockbox.c b/apps/plugins/pdbox/PDa/src/s_audio_rockbox.c
index 56fa2060b4..3c1bb6532b 100644
--- a/apps/plugins/pdbox/PDa/src/s_audio_rockbox.c
+++ b/apps/plugins/pdbox/PDa/src/s_audio_rockbox.c
@@ -131,45 +131,46 @@ int rockbox_send_dacs(void)
131 if(outbuf_fill >= OUTBUFSIZE-1) 131 if(outbuf_fill >= OUTBUFSIZE-1)
132 return SENDDACS_NO; 132 return SENDDACS_NO;
133 133
134 /* Write the block of sound. */ 134 do
135write_block:
136 for(out = outbuf[outbuf_head].data +
137 outbuf[outbuf_head].fill * PD_OUT_CHANNELS;
138 outbuf[outbuf_head].fill < (AUDIOBUFSIZE / PD_OUT_CHANNELS) &&
139 samples_out < DEFDACBLKSIZE;
140 left++, right++, samples_out++, outbuf[outbuf_head].fill++)
141 { 135 {
142 /* Copy samples from both channels. */ 136 /* Write the block of sound. */
143 sample = SCALE16(*left); 137 for(out = outbuf[outbuf_head].data +
144 if(sample > 32767) 138 outbuf[outbuf_head].fill * PD_OUT_CHANNELS;
145 sample = 32767; 139 outbuf[outbuf_head].fill < (AUDIOBUFSIZE / PD_OUT_CHANNELS) &&
146 else if(sample < -32767) 140 samples_out < DEFDACBLKSIZE;
147 sample = -32767; 141 left++, right++, samples_out++, outbuf[outbuf_head].fill++)
148 *out++ = sample; 142 {
149 sample = SCALE16(*right); 143 /* Copy samples from both channels. */
150 if(sample > 32767) 144 sample = SCALE16(*left);
151 sample = 32767; 145 if(sample > 32767)
152 else if(sample < -32767) 146 sample = 32767;
153 sample = -32767; 147 else if(sample < -32767)
154 *out++ = sample; 148 sample = -32767;
155 } 149 *out++ = sample;
156 150 sample = SCALE16(*right);
157 /* If part of output buffer filled... */ 151 if(sample > 32767)
158 if(outbuf[outbuf_head].fill >= (AUDIOBUFSIZE / PD_OUT_CHANNELS)) 152 sample = 32767;
159 { 153 else if(sample < -32767)
160 /* Advance one part of output buffer. */ 154 sample = -32767;
161 if(outbuf_head == OUTBUFSIZE-1) 155 *out++ = sample;
162 outbuf_head = 0; 156 }
163 else 157
164 outbuf_head++; 158 /* If part of output buffer filled... */
165 159 if(outbuf[outbuf_head].fill >= (AUDIOBUFSIZE / PD_OUT_CHANNELS))
166 /* Increase fill counter. */ 160 {
167 outbuf_fill++; 161 /* Advance one part of output buffer. */
168 } 162 if(outbuf_head == OUTBUFSIZE-1)
163 outbuf_head = 0;
164 else
165 outbuf_head++;
166
167 /* Increase fill counter. */
168 outbuf_fill++;
169 }
169 170
170 /* If needed, fill the next frame. */ 171 /* If needed, fill the next frame. */
171 if(samples_out < DEFDACBLKSIZE) 172 }
172 goto write_block; 173 while(samples_out < DEFDACBLKSIZE);
173 174
174 /* Clear Pure Data output buffer. */ 175 /* Clear Pure Data output buffer. */
175 memset(sys_soundout, 176 memset(sys_soundout,
diff --git a/apps/plugins/pdbox/pdbox.h b/apps/plugins/pdbox/pdbox.h
index 1416990f5e..a5dadbc938 100644
--- a/apps/plugins/pdbox/pdbox.h
+++ b/apps/plugins/pdbox/pdbox.h
@@ -32,7 +32,7 @@
32#include "PDa/src/m_pd.h" 32#include "PDa/src/m_pd.h"
33 33
34/* Minimal memory size. */ 34/* Minimal memory size. */
35#define MIN_MEM_SIZE (2 * 1024 * 1024) 35#define MIN_MEM_SIZE (4 * 1024 * 1024)
36 36
37/* Memory prototypes. */ 37/* Memory prototypes. */
38 38
@@ -49,7 +49,11 @@
49#define PD_OUT_CHANNELS 2 49#define PD_OUT_CHANNELS 2
50 50
51/* Audio buffer part. Contains data for one HZ period. */ 51/* Audio buffer part. Contains data for one HZ period. */
52#ifdef SIMULATOR
53#define AUDIOBUFSIZE (PD_SAMPLES_PER_HZ * PD_OUT_CHANNELS * 16)
54#else
52#define AUDIOBUFSIZE (PD_SAMPLES_PER_HZ * PD_OUT_CHANNELS) 55#define AUDIOBUFSIZE (PD_SAMPLES_PER_HZ * PD_OUT_CHANNELS)
56#endif
53struct audio_buffer 57struct audio_buffer
54{ 58{
55 int16_t data[AUDIOBUFSIZE]; 59 int16_t data[AUDIOBUFSIZE];