summaryrefslogtreecommitdiff
path: root/apps/plugins/pdbox/PDa
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/pdbox/PDa')
-rw-r--r--apps/plugins/pdbox/PDa/src/s_audio_rockbox.c73
1 files changed, 37 insertions, 36 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,