comparison src/audio/nds/SDL_ndsaudio.c @ 2689:e065c9f6a393 gsoc2008_nds

Some audio work, setting default frequency, volume, etc. and calling a generic playback function that uses them.
author Darren Alton <dalton@stevens.edu>
date Fri, 15 Aug 2008 10:44:31 +0000
parents 2190b873ff00
children c9121b04cffa
comparison
equal deleted inserted replaced
2688:71c56e900f8b 2689:e065c9f6a393
32 #include "SDL_ndsaudio.h" 32 #include "SDL_ndsaudio.h"
33 33
34 static int 34 static int
35 NDSAUD_OpenDevice(_THIS, const char *devname, int iscapture) 35 NDSAUD_OpenDevice(_THIS, const char *devname, int iscapture)
36 { 36 {
37 return 1; /* always succeeds. */ 37 SDL_AudioFormat test_format = SDL_FirstAudioFormat(this->spec.format);
38 int valid_datatype = 0;
39
40 this->hidden = SDL_malloc(sizeof(*(this->hidden)));
41 if(!this->hidden) {
42 SDL_OutOfMemory();
43 return 0;
44 }
45 SDL_memset(this->hidden, 0, (sizeof *this->hidden));
46
47 while ((!valid_datatype) && (test_format)) {
48 this->spec.format = test_format;
49 switch (test_format) {
50 case AUDIO_S8:
51 /*case AUDIO_S16LSB:*/
52 valid_datatype = 1;
53 break;
54 default:
55 test_format = SDL_NextAudioFormat();
56 break;
57 }
58 }
59
60 /* set the generic sound parameters */
61 setGenericSound(22050, /* sample rate */
62 127, /* volume */
63 64, /* panning/balance */
64 0); /* sound format*/
65
66 return 1;
38 } 67 }
39 68
40 static void 69 static void
41 NDSAUD_PlayDevice(_THIS) 70 NDSAUD_PlayDevice(_THIS)
42 { 71 {
43 TransferSoundData* sound = SDL_malloc(sizeof(TransferSoundData)); 72 TransferSoundData* sound = SDL_malloc(sizeof(TransferSoundData));
44 if(!sound) { 73 if(!sound) {
45 SDL_OutOfMemory(); 74 SDL_OutOfMemory();
46 } 75 }
47 sound->data = NULL; /* pointer to raw audio data */ 76
48 sound->len = 0; /* size of raw data pointed to above */ 77 playGenericSound(this->hidden->mixbuf, this->hidden->mixlen);
49 sound->rate = 22050; /* sample rate = 22050Hz */ 78
50 sound->vol = 127; /* volume [0..127] for [min..max] */ 79 // sound->data = this->hidden->mixbuf;/* pointer to raw audio data */
51 sound->pan = 64; /* balance [0..127] for [left..right] */ 80 // sound->len = this->hidden->mixlen; /* size of raw data pointed to above */
52 sound->format = 0; /* 0 for 16-bit, 1 for 8-bit */ 81 // sound->rate = 22050; /* sample rate = 22050Hz */
53 /*playSound(sound);*/ 82 // sound->vol = 127; /* volume [0..127] for [min..max] */
54 /* stub */ 83 // sound->pan = 64; /* balance [0..127] for [left..right] */
84 // sound->format = 0; /* 0 for 16-bit, 1 for 8-bit */
85 // playSound(sound);
55 } 86 }
56 87
57 88
58 static Uint8 * 89 static Uint8 *
59 NDSAUD_GetDeviceBuf(_THIS) 90 NDSAUD_GetDeviceBuf(_THIS)
60 { 91 { /* is this right? */
61 /* stub */ 92 return this->hidden->mixbuf;
62 } 93 }
63 94
64 static void 95 static void
65 NDSAUD_WaitDevice(_THIS) 96 NDSAUD_WaitDevice(_THIS)
66 { 97 {