diff options
| author | Wincent Balin <wincent@rockbox.org> | 2010-06-01 20:37:16 +0000 |
|---|---|---|
| committer | Wincent Balin <wincent@rockbox.org> | 2010-06-01 20:37:16 +0000 |
| commit | f52c9aae3a04ae4c767c2da1d788421686805fea (patch) | |
| tree | 2050e9bcdb6797c16f4acbd2567686a07dab9e1b /apps/plugins | |
| parent | 279969618d28e23ac83b6e81c7b7bbf1adaf5b74 (diff) | |
| download | rockbox-f52c9aae3a04ae4c767c2da1d788421686805fea.zip rockbox-f52c9aae3a04ae4c767c2da1d788421686805fea.tar.gz rockbox-f52c9aae3a04ae4c767c2da1d788421686805fea.tar.bz2 rockbox-f52c9aae3a04ae4c767c2da1d788421686805fea.tar.xz | |
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')
| -rw-r--r-- | apps/plugins/pdbox/PDa/src/s_audio_rockbox.c | 73 | ||||
| -rw-r--r-- | apps/plugins/pdbox/pdbox.h | 6 |
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 56fa206..3c1bb65 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) if(outbuf_fill >= OUTBUFSIZE-1) return SENDDACS_NO; - /* Write the block of sound. */ -write_block: - for(out = outbuf[outbuf_head].data + - outbuf[outbuf_head].fill * PD_OUT_CHANNELS; - outbuf[outbuf_head].fill < (AUDIOBUFSIZE / PD_OUT_CHANNELS) && - samples_out < DEFDACBLKSIZE; - left++, right++, samples_out++, outbuf[outbuf_head].fill++) + do { - /* Copy samples from both channels. */ - sample = SCALE16(*left); - if(sample > 32767) - sample = 32767; - else if(sample < -32767) - sample = -32767; - *out++ = sample; - sample = SCALE16(*right); - if(sample > 32767) - sample = 32767; - else if(sample < -32767) - sample = -32767; - *out++ = sample; - } - - /* If part of output buffer filled... */ - if(outbuf[outbuf_head].fill >= (AUDIOBUFSIZE / PD_OUT_CHANNELS)) - { - /* Advance one part of output buffer. */ - if(outbuf_head == OUTBUFSIZE-1) - outbuf_head = 0; - else - outbuf_head++; - - /* Increase fill counter. */ - outbuf_fill++; - } + /* Write the block of sound. */ + for(out = outbuf[outbuf_head].data + + outbuf[outbuf_head].fill * PD_OUT_CHANNELS; + outbuf[outbuf_head].fill < (AUDIOBUFSIZE / PD_OUT_CHANNELS) && + samples_out < DEFDACBLKSIZE; + left++, right++, samples_out++, outbuf[outbuf_head].fill++) + { + /* Copy samples from both channels. */ + sample = SCALE16(*left); + if(sample > 32767) + sample = 32767; + else if(sample < -32767) + sample = -32767; + *out++ = sample; + sample = SCALE16(*right); + if(sample > 32767) + sample = 32767; + else if(sample < -32767) + sample = -32767; + *out++ = sample; + } + + /* If part of output buffer filled... */ + if(outbuf[outbuf_head].fill >= (AUDIOBUFSIZE / PD_OUT_CHANNELS)) + { + /* Advance one part of output buffer. */ + if(outbuf_head == OUTBUFSIZE-1) + outbuf_head = 0; + else + outbuf_head++; + + /* Increase fill counter. */ + outbuf_fill++; + } /* If needed, fill the next frame. */ - if(samples_out < DEFDACBLKSIZE) - goto write_block; + } + while(samples_out < DEFDACBLKSIZE); /* Clear Pure Data output buffer. */ memset(sys_soundout, diff --git a/apps/plugins/pdbox/pdbox.h b/apps/plugins/pdbox/pdbox.h index 1416990..a5dadbc 100644 --- a/apps/plugins/pdbox/pdbox.h +++ b/apps/plugins/pdbox/pdbox.h @@ -32,7 +32,7 @@ #include "PDa/src/m_pd.h" /* Minimal memory size. */ -#define MIN_MEM_SIZE (2 * 1024 * 1024) +#define MIN_MEM_SIZE (4 * 1024 * 1024) /* Memory prototypes. */ @@ -49,7 +49,11 @@ #define PD_OUT_CHANNELS 2 /* Audio buffer part. Contains data for one HZ period. */ +#ifdef SIMULATOR +#define AUDIOBUFSIZE (PD_SAMPLES_PER_HZ * PD_OUT_CHANNELS * 16) +#else #define AUDIOBUFSIZE (PD_SAMPLES_PER_HZ * PD_OUT_CHANNELS) +#endif struct audio_buffer { int16_t data[AUDIOBUFSIZE]; |