comparison src/audio/nto/SDL_nto_audio.c @ 1336:3692456e7b0f

Use SDL_ prefixed versions of C library functions. FIXME: Change #include <stdlib.h> to #include "SDL_stdlib.h" Change #include <string.h> to #include "SDL_string.h" Make sure nothing else broke because of this...
author Sam Lantinga <slouken@libsdl.org>
date Tue, 07 Feb 2006 06:59:48 +0000
parents b8d311d90021
children 604d73db6802
comparison
equal deleted inserted replaced
1335:c39265384763 1336:3692456e7b0f
92 return 0; 92 return 0;
93 } 93 }
94 94
95 for (it=0; it<QSA_WA_CARDS; it++) 95 for (it=0; it<QSA_WA_CARDS; it++)
96 { 96 {
97 if (strcmp(buggycards[it].cardname, scardname)==0) 97 if (SDL_strcmp(buggycards[it].cardname, scardname)==0)
98 { 98 {
99 if (buggycards[it].bugtype==checkfor) 99 if (buggycards[it].bugtype==checkfor)
100 { 100 {
101 return 1; 101 return 1;
102 } 102 }
118 } 118 }
119 119
120 /* PCM transfer channel parameters initialize function */ 120 /* PCM transfer channel parameters initialize function */
121 static void NTO_InitAudioParams(snd_pcm_channel_params_t* cpars) 121 static void NTO_InitAudioParams(snd_pcm_channel_params_t* cpars)
122 { 122 {
123 memset(cpars, 0, sizeof(snd_pcm_channel_params_t)); 123 SDL_memset(cpars, 0, sizeof(snd_pcm_channel_params_t));
124 124
125 cpars->channel = SND_PCM_CHANNEL_PLAYBACK; 125 cpars->channel = SND_PCM_CHANNEL_PLAYBACK;
126 cpars->mode = SND_PCM_MODE_BLOCK; 126 cpars->mode = SND_PCM_MODE_BLOCK;
127 cpars->start_mode = SND_PCM_START_DATA; 127 cpars->start_mode = SND_PCM_START_DATA;
128 cpars->stop_mode = SND_PCM_STOP_STOP; 128 cpars->stop_mode = SND_PCM_STOP_STOP;
170 170
171 static void NTO_DeleteAudioDevice(SDL_AudioDevice *device) 171 static void NTO_DeleteAudioDevice(SDL_AudioDevice *device)
172 { 172 {
173 if ((device)&&(device->hidden)) 173 if ((device)&&(device->hidden))
174 { 174 {
175 free(device->hidden); 175 SDL_free(device->hidden);
176 } 176 }
177 if (device) 177 if (device)
178 { 178 {
179 free(device); 179 SDL_free(device);
180 } 180 }
181 } 181 }
182 182
183 static SDL_AudioDevice* NTO_CreateAudioDevice(int devindex) 183 static SDL_AudioDevice* NTO_CreateAudioDevice(int devindex)
184 { 184 {
185 SDL_AudioDevice *this; 185 SDL_AudioDevice *this;
186 186
187 /* Initialize all variables that we clean on shutdown */ 187 /* Initialize all variables that we clean on shutdown */
188 this = (SDL_AudioDevice *)malloc(sizeof(SDL_AudioDevice)); 188 this = (SDL_AudioDevice *)SDL_malloc(sizeof(SDL_AudioDevice));
189 if (this) 189 if (this)
190 { 190 {
191 memset(this, 0, sizeof(SDL_AudioDevice)); 191 SDL_memset(this, 0, sizeof(SDL_AudioDevice));
192 this->hidden = (struct SDL_PrivateAudioData *)malloc(sizeof(struct SDL_PrivateAudioData)); 192 this->hidden = (struct SDL_PrivateAudioData *)SDL_malloc(sizeof(struct SDL_PrivateAudioData));
193 } 193 }
194 if ((this == NULL) || (this->hidden == NULL)) 194 if ((this == NULL) || (this->hidden == NULL))
195 { 195 {
196 SDL_OutOfMemory(); 196 SDL_OutOfMemory();
197 if (this) 197 if (this)
198 { 198 {
199 free(this); 199 SDL_free(this);
200 } 200 }
201 return (0); 201 return (0);
202 } 202 }
203 memset(this->hidden, 0, sizeof(struct SDL_PrivateAudioData)); 203 SDL_memset(this->hidden, 0, sizeof(struct SDL_PrivateAudioData));
204 audio_handle = NULL; 204 audio_handle = NULL;
205 205
206 /* Set the function pointers */ 206 /* Set the function pointers */
207 this->ThreadInit = NTO_ThreadInit; 207 this->ThreadInit = NTO_ThreadInit;
208 this->OpenAudio = NTO_OpenAudio; 208 this->OpenAudio = NTO_OpenAudio;
278 } 278 }
279 else 279 else
280 { 280 {
281 if ((errno == EINVAL) || (errno == EIO)) 281 if ((errno == EINVAL) || (errno == EIO))
282 { 282 {
283 memset(&cstatus, 0, sizeof(cstatus)); 283 SDL_memset(&cstatus, 0, sizeof(cstatus));
284 cstatus.channel = SND_PCM_CHANNEL_PLAYBACK; 284 cstatus.channel = SND_PCM_CHANNEL_PLAYBACK;
285 if ((rval = snd_pcm_plugin_status(audio_handle, &cstatus)) < 0) 285 if ((rval = snd_pcm_plugin_status(audio_handle, &cstatus)) < 0)
286 { 286 {
287 SDL_SetError("NTO_PlayAudio(): snd_pcm_plugin_status failed: %s\n", snd_strerror(rval)); 287 SDL_SetError("NTO_PlayAudio(): snd_pcm_plugin_status failed: %s\n", snd_strerror(rval));
288 return; 288 return;
453 SDL_SetError("NTO_OpenAudio(): snd_pcm_channel_params failed: %s\n", snd_strerror(rval)); 453 SDL_SetError("NTO_OpenAudio(): snd_pcm_channel_params failed: %s\n", snd_strerror(rval));
454 return (-1); 454 return (-1);
455 } 455 }
456 456
457 /* Make sure channel is setup right one last time */ 457 /* Make sure channel is setup right one last time */
458 memset(&csetup, 0x00, sizeof(csetup)); 458 SDL_memset(&csetup, 0x00, sizeof(csetup));
459 csetup.channel = SND_PCM_CHANNEL_PLAYBACK; 459 csetup.channel = SND_PCM_CHANNEL_PLAYBACK;
460 if (snd_pcm_plugin_setup(audio_handle, &csetup) < 0) 460 if (snd_pcm_plugin_setup(audio_handle, &csetup) < 0)
461 { 461 {
462 SDL_SetError("NTO_OpenAudio(): Unable to setup playback channel\n"); 462 SDL_SetError("NTO_OpenAudio(): Unable to setup playback channel\n");
463 return -1; 463 return -1;
481 if (pcm_buf == NULL) 481 if (pcm_buf == NULL)
482 { 482 {
483 SDL_SetError("NTO_OpenAudio(): pcm buffer allocation failed\n"); 483 SDL_SetError("NTO_OpenAudio(): pcm buffer allocation failed\n");
484 return (-1); 484 return (-1);
485 } 485 }
486 memset(pcm_buf, spec->silence, pcm_len); 486 SDL_memset(pcm_buf, spec->silence, pcm_len);
487 487
488 /* get the file descriptor */ 488 /* get the file descriptor */
489 if ((audio_fd = snd_pcm_file_descriptor(audio_handle, SND_PCM_CHANNEL_PLAYBACK)) < 0) 489 if ((audio_fd = snd_pcm_file_descriptor(audio_handle, SND_PCM_CHANNEL_PLAYBACK)) < 0)
490 { 490 {
491 SDL_SetError("NTO_OpenAudio(): snd_pcm_file_descriptor failed with error code: %s\n", snd_strerror(rval)); 491 SDL_SetError("NTO_OpenAudio(): snd_pcm_file_descriptor failed with error code: %s\n", snd_strerror(rval));