comparison src/audio/nds/SDL_ndsaudio.c @ 2697:c9121b04cffa gsoc2008_nds

Some more work on the audio driver.
author Darren Alton <dalton@stevens.edu>
date Thu, 21 Aug 2008 12:38:21 +0000
parents e065c9f6a393
children e1da92da346c
comparison
equal deleted inserted replaced
2696:0b395a60deff 2697:c9121b04cffa
29 29
30 #include "SDL_audio.h" 30 #include "SDL_audio.h"
31 #include "../SDL_audio_c.h" 31 #include "../SDL_audio_c.h"
32 #include "SDL_ndsaudio.h" 32 #include "SDL_ndsaudio.h"
33 33
34 #define TRACE printf
35
34 static int 36 static int
35 NDSAUD_OpenDevice(_THIS, const char *devname, int iscapture) 37 NDSAUD_OpenDevice(_THIS, const char *devname, int iscapture)
36 { 38 {
37 SDL_AudioFormat test_format = SDL_FirstAudioFormat(this->spec.format); 39 SDL_AudioFormat test_format = SDL_FirstAudioFormat(this->spec.format);
38 int valid_datatype = 0; 40 int valid_datatype = 0;
42 SDL_OutOfMemory(); 44 SDL_OutOfMemory();
43 return 0; 45 return 0;
44 } 46 }
45 SDL_memset(this->hidden, 0, (sizeof *this->hidden)); 47 SDL_memset(this->hidden, 0, (sizeof *this->hidden));
46 48
49 TRACE("+NDSAUD_OpenDevice\n");
47 while ((!valid_datatype) && (test_format)) { 50 while ((!valid_datatype) && (test_format)) {
48 this->spec.format = test_format; 51 this->spec.format = test_format;
49 switch (test_format) { 52 switch (test_format) {
50 case AUDIO_S8: 53 case AUDIO_S8:
51 /*case AUDIO_S16LSB:*/ 54 /*case AUDIO_S16LSB:*/
61 setGenericSound(22050, /* sample rate */ 64 setGenericSound(22050, /* sample rate */
62 127, /* volume */ 65 127, /* volume */
63 64, /* panning/balance */ 66 64, /* panning/balance */
64 0); /* sound format*/ 67 0); /* sound format*/
65 68
69 TRACE("-NDSAUD_OpenDevice\n");
66 return 1; 70 return 1;
67 } 71 }
68 72
69 static void 73 static void
70 NDSAUD_PlayDevice(_THIS) 74 NDSAUD_PlayDevice(_THIS)
71 { 75 {
72 TransferSoundData* sound = SDL_malloc(sizeof(TransferSoundData)); 76 TransferSoundData* sound = SDL_malloc(sizeof(TransferSoundData));
73 if(!sound) { 77 if(!sound) {
74 SDL_OutOfMemory(); 78 SDL_OutOfMemory();
75 } 79 }
80 TRACE("+NDSAUD_PlayDevice\n");
76 81
77 playGenericSound(this->hidden->mixbuf, this->hidden->mixlen); 82 playGenericSound(this->hidden->mixbuf, this->hidden->mixlen);
78 83
84 TRACE("-NDSAUD_PlayDevice\n");
79 // sound->data = this->hidden->mixbuf;/* pointer to raw audio data */ 85 // sound->data = this->hidden->mixbuf;/* pointer to raw audio data */
80 // sound->len = this->hidden->mixlen; /* size of raw data pointed to above */ 86 // sound->len = this->hidden->mixlen; /* size of raw data pointed to above */
81 // sound->rate = 22050; /* sample rate = 22050Hz */ 87 // sound->rate = 22050; /* sample rate = 22050Hz */
82 // sound->vol = 127; /* volume [0..127] for [min..max] */ 88 // sound->vol = 127; /* volume [0..127] for [min..max] */
83 // sound->pan = 64; /* balance [0..127] for [left..right] */ 89 // sound->pan = 64; /* balance [0..127] for [left..right] */
87 93
88 94
89 static Uint8 * 95 static Uint8 *
90 NDSAUD_GetDeviceBuf(_THIS) 96 NDSAUD_GetDeviceBuf(_THIS)
91 { /* is this right? */ 97 { /* is this right? */
98 TRACE("!NDSAUD_GetDeviceBuf\n");
92 return this->hidden->mixbuf; 99 return this->hidden->mixbuf;
93 } 100 }
94 101
95 static void 102 static void
96 NDSAUD_WaitDevice(_THIS) 103 NDSAUD_WaitDevice(_THIS)
97 { 104 {
98 /* stub */ 105 /* stub */
106 TRACE("!NDSAUD_WaitDevice\n");
99 } 107 }
100 108
101 static void 109 static void
102 NDSAUD_CloseDevice(_THIS) 110 NDSAUD_CloseDevice(_THIS)
103 { 111 {
104 /* stub */ 112 /* stub */
113 TRACE("!NDSAUD_CloseDevice\n");
105 } 114 }
106 115
107 static int 116 static int
108 NDSAUD_Init(SDL_AudioDriverImpl * impl) 117 NDSAUD_Init(SDL_AudioDriverImpl * impl)
109 { 118 {
119 TRACE("+NDSAUD_Init\n");
120
110 /* Set the function pointers */ 121 /* Set the function pointers */
111 impl->OpenDevice = NDSAUD_OpenDevice; 122 impl->OpenDevice = NDSAUD_OpenDevice;
112 impl->PlayDevice = NDSAUD_PlayDevice; 123 impl->PlayDevice = NDSAUD_PlayDevice;
113 impl->WaitDevice = NDSAUD_WaitDevice; 124 impl->WaitDevice = NDSAUD_WaitDevice;
114 impl->GetDeviceBuf = NDSAUD_GetDeviceBuf; 125 impl->GetDeviceBuf = NDSAUD_GetDeviceBuf;
115 impl->CloseDevice = NDSAUD_CloseDevice; 126 impl->CloseDevice = NDSAUD_CloseDevice;
127
128 /* and the capabilities */
129 impl->HasCaptureSupport = 1;
116 impl->OnlyHasDefaultOutputDevice = 1; 130 impl->OnlyHasDefaultOutputDevice = 1;
131 impl->OnlyHasDefaultInputDevice = 1;
132
133 TRACE("-NDSAUD_Init\n");
117 return 1; 134 return 1;
118 } 135 }
119 136
120 AudioBootStrap NDSAUD_bootstrap = { 137 AudioBootStrap NDSAUD_bootstrap = {
121 "nds", "SDL NDS audio driver", NDSAUD_Init, 1 138 "nds", "SDL NDS audio driver", NDSAUD_Init, 0 /*1?*/
122 }; 139 };
123 140
124 /* vi: set ts=4 sw=4 expandtab: */ 141 /* vi: set ts=4 sw=4 expandtab: */