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