Some audio work, setting default frequency, volume, etc. and calling a generic playback function that uses them.
1.1 --- a/src/audio/nds/SDL_ndsaudio.c Fri Aug 15 10:17:07 2008 +0000
1.2 +++ b/src/audio/nds/SDL_ndsaudio.c Fri Aug 15 10:44:31 2008 +0000
1.3 @@ -34,7 +34,36 @@
1.4 static int
1.5 NDSAUD_OpenDevice(_THIS, const char *devname, int iscapture)
1.6 {
1.7 - return 1; /* always succeeds. */
1.8 + SDL_AudioFormat test_format = SDL_FirstAudioFormat(this->spec.format);
1.9 + int valid_datatype = 0;
1.10 +
1.11 + this->hidden = SDL_malloc(sizeof(*(this->hidden)));
1.12 + if(!this->hidden) {
1.13 + SDL_OutOfMemory();
1.14 + return 0;
1.15 + }
1.16 + SDL_memset(this->hidden, 0, (sizeof *this->hidden));
1.17 +
1.18 + while ((!valid_datatype) && (test_format)) {
1.19 + this->spec.format = test_format;
1.20 + switch (test_format) {
1.21 + case AUDIO_S8:
1.22 + /*case AUDIO_S16LSB:*/
1.23 + valid_datatype = 1;
1.24 + break;
1.25 + default:
1.26 + test_format = SDL_NextAudioFormat();
1.27 + break;
1.28 + }
1.29 + }
1.30 +
1.31 + /* set the generic sound parameters */
1.32 + setGenericSound(22050, /* sample rate */
1.33 + 127, /* volume */
1.34 + 64, /* panning/balance */
1.35 + 0); /* sound format*/
1.36 +
1.37 + return 1;
1.38 }
1.39
1.40 static void
1.41 @@ -44,21 +73,23 @@
1.42 if(!sound) {
1.43 SDL_OutOfMemory();
1.44 }
1.45 - sound->data = NULL; /* pointer to raw audio data */
1.46 - sound->len = 0; /* size of raw data pointed to above */
1.47 - sound->rate = 22050; /* sample rate = 22050Hz */
1.48 - sound->vol = 127; /* volume [0..127] for [min..max] */
1.49 - sound->pan = 64; /* balance [0..127] for [left..right] */
1.50 - sound->format = 0; /* 0 for 16-bit, 1 for 8-bit */
1.51 - /*playSound(sound);*/
1.52 - /* stub */
1.53 +
1.54 + playGenericSound(this->hidden->mixbuf, this->hidden->mixlen);
1.55 +
1.56 +// sound->data = this->hidden->mixbuf;/* pointer to raw audio data */
1.57 +// sound->len = this->hidden->mixlen; /* size of raw data pointed to above */
1.58 +// sound->rate = 22050; /* sample rate = 22050Hz */
1.59 +// sound->vol = 127; /* volume [0..127] for [min..max] */
1.60 +// sound->pan = 64; /* balance [0..127] for [left..right] */
1.61 +// sound->format = 0; /* 0 for 16-bit, 1 for 8-bit */
1.62 +// playSound(sound);
1.63 }
1.64
1.65
1.66 static Uint8 *
1.67 NDSAUD_GetDeviceBuf(_THIS)
1.68 -{
1.69 - /* stub */
1.70 +{ /* is this right? */
1.71 + return this->hidden->mixbuf;
1.72 }
1.73
1.74 static void
2.1 --- a/src/audio/nds/SDL_ndsaudio.h Fri Aug 15 10:17:07 2008 +0000
2.2 +++ b/src/audio/nds/SDL_ndsaudio.h Fri Aug 15 10:44:31 2008 +0000
2.3 @@ -25,12 +25,14 @@
2.4 #define _SDL_ndsaudio_h
2.5
2.6 #include "../SDL_sysaudio.h"
2.7 +#include <nds/arm9/sound.h>
2.8
2.9 /* Hidden "this" pointer for the audio functions */
2.10 #define _THIS SDL_AudioDevice *this
2.11
2.12 struct SDL_PrivateAudioData
2.13 {
2.14 + TransferSoundData* sound;
2.15 /* The file descriptor for the audio device */
2.16 Uint8 *mixbuf;
2.17 Uint32 mixlen;