Mercurial > hg > xmms-sid
comparison src/xs_sidplay2.cc @ 127:ddb513bd2610
Improved audio format support, now supported formats are "queried" from
emulator engines. Preparing for NanoSID-support, since it's the worst
in this sense.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 14 Jan 2004 21:45:05 +0000 |
parents | fe83646e6baa |
children | 608f31f6c095 |
comparison
equal
deleted
inserted
replaced
126:4f4dba82011e | 127:ddb513bd2610 |
---|---|
196 | 196 |
197 | 197 |
198 guint xs_sidplay2_fillbuffer(t_xs_status *myStatus, gchar *audioBuffer, guint audioBufSize) | 198 guint xs_sidplay2_fillbuffer(t_xs_status *myStatus, gchar *audioBuffer, guint audioBufSize) |
199 { | 199 { |
200 t_xs_sidplay2 *myPlayer = (t_xs_sidplay2 *) myStatus->player; | 200 t_xs_sidplay2 *myPlayer = (t_xs_sidplay2 *) myStatus->player; |
201 guint nData, i; | 201 |
202 guchar *p; | 202 return myPlayer->currEng->play(audioBuffer, audioBufSize); |
203 | |
204 nData = myPlayer->currEng->play(audioBuffer, audioBufSize); | |
205 | |
206 if ((nData > 0) && (myPlayer->currConfig.precision == 8)) | |
207 { | |
208 /* SIDPlay2 only outputs SIGNED 8bit, so we need to convert it */ | |
209 i = nData; | |
210 p = (guchar *) audioBuffer; | |
211 while (i--) *(p++) ^= 0x80; | |
212 } | |
213 | |
214 return nData; | |
215 } | 203 } |
216 | 204 |
217 | 205 |
218 gboolean xs_sidplay2_loadsid(t_xs_status *myStatus, gchar *pcFilename) | 206 gboolean xs_sidplay2_loadsid(t_xs_status *myStatus, gchar *pcFilename) |
219 { | 207 { |
226 | 214 |
227 /* Get current configuration */ | 215 /* Get current configuration */ |
228 myPlayer->currConfig = myPlayer->currEng->config(); | 216 myPlayer->currConfig = myPlayer->currEng->config(); |
229 | 217 |
230 /* Configure channels and stuff */ | 218 /* Configure channels and stuff */ |
231 switch (xs_cfg.fmtChannels) { | 219 switch (myStatus->audioChannels) { |
232 | 220 |
233 case XS_CHN_AUTOPAN: | 221 case XS_CHN_AUTOPAN: |
234 myPlayer->currConfig.playback = sid2_stereo; | 222 myPlayer->currConfig.playback = sid2_stereo; |
235 break; | 223 break; |
236 | 224 |
279 } | 267 } |
280 | 268 |
281 | 269 |
282 /* Configure rest of the emulation */ | 270 /* Configure rest of the emulation */ |
283 myPlayer->currConfig.sidEmulation = myPlayer->currBuilder; | 271 myPlayer->currConfig.sidEmulation = myPlayer->currBuilder; |
284 myPlayer->currConfig.precision = xs_cfg.fmtBitsPerSample; | |
285 myPlayer->currConfig.frequency = xs_cfg.fmtFrequency; | |
286 myPlayer->currConfig.clockForced = xs_cfg.forceSpeed; | 272 myPlayer->currConfig.clockForced = xs_cfg.forceSpeed; |
287 myPlayer->currConfig.optimisation = (xs_cfg.sid2OptLevel) ? 1 : 0; | 273 myPlayer->currConfig.optimisation = (xs_cfg.sid2OptLevel) ? 1 : 0; |
288 myPlayer->currConfig.sidDefault = myPlayer->currConfig.sidModel = (xs_cfg.mos8580) ? SID2_MOS8580 : SID2_MOS6581; | 274 myPlayer->currConfig.sidDefault = myPlayer->currConfig.sidModel = (xs_cfg.mos8580) ? SID2_MOS8580 : SID2_MOS6581; |
289 myPlayer->currConfig.sidSamples = TRUE; // FIXME FIX ME, make configurable! | 275 myPlayer->currConfig.sidSamples = TRUE; // FIXME FIX ME, make configurable! |
290 | 276 myPlayer->currConfig.precision = myStatus->audioBitsPerSample; |
291 #ifdef HAVE_UNSIGNEDPCM | 277 myPlayer->currConfig.frequency = myStatus->audioFrequency; |
278 | |
279 switch (myStatus->audioBitsPerSample) { | |
280 case XS_RES_8BIT: | |
281 myStatus->audioFormat = FMT_U8; | |
282 myPlayer->currConfig.sampleFormat = SID2_LITTLE_UNSIGNED; | |
283 break; | |
284 | |
285 case XS_RES_16BIT: | |
286 switch (myStatus->audioFormat) { | |
287 case FMT_U16_LE: | |
288 myPlayer->currConfig.sampleFormat = SID2_LITTLE_UNSIGNED; | |
289 break; | |
290 | |
291 case FMT_U16_BE: | |
292 myPlayer->currConfig.sampleFormat = SID2_BIG_UNSIGNED; | |
293 break; | |
294 | |
295 case FMT_U16_NE: | |
296 myStatus->audioFormat = FMT_U16_NE; | |
292 #ifdef WORDS_BIGENDIAN | 297 #ifdef WORDS_BIGENDIAN |
293 myPlayer->currConfig.sampleFormat = SID2_BIG_UNSIGNED; | 298 myPlayer->currConfig.sampleFormat = SID2_BIG_UNSIGNED; |
294 #else | 299 #else |
295 myPlayer->currConfig.sampleFormat = SID2_LITTLE_UNSIGNED; | 300 myPlayer->currConfig.sampleFormat = SID2_LITTLE_UNSIGNED; |
296 #endif | 301 #endif |
302 break; | |
303 | |
304 case FMT_S16_LE: | |
305 myPlayer->currConfig.sampleFormat = SID2_LITTLE_SIGNED; | |
306 break; | |
307 | |
308 case FMT_S16_BE: | |
309 myPlayer->currConfig.sampleFormat = SID2_BIG_SIGNED; | |
310 break; | |
311 | |
312 default: | |
313 myStatus->audioFormat = FMT_S16_NE; | |
314 #ifdef WORDS_BIGENDIAN | |
315 myPlayer->currConfig.sampleFormat = SID2_BIG_SIGNED; | |
297 #else | 316 #else |
298 #ifdef WORDS_BIGENDIAN | 317 myPlayer->currConfig.sampleFormat = SID2_LITTLE_SIGNED; |
299 myPlayer->currConfig.sampleFormat = SID2_BIG_SIGNED; | 318 #endif |
300 #else | 319 break; |
301 myPlayer->currConfig.sampleFormat = SID2_LITTLE_SIGNED; | 320 |
302 #endif | 321 } |
303 #endif | 322 break; |
323 } | |
324 | |
304 | 325 |
305 /* Now set the emulator configuration */ | 326 /* Now set the emulator configuration */ |
306 if (myPlayer->currEng->config(myPlayer->currConfig) < 0) | 327 if (myPlayer->currEng->config(myPlayer->currConfig) < 0) |
307 { | 328 { |
308 XSERR("Emulator engine configuration failed!\n"); | 329 XSERR("Emulator engine configuration failed!\n"); |