Mercurial > sdl-ios-xcode
comparison src/audio/windib/SDL_dibaudio.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 | 450721ad5436 |
children | 604d73db6802 |
comparison
equal
deleted
inserted
replaced
1335:c39265384763 | 1336:3692456e7b0f |
---|---|
53 return(1); | 53 return(1); |
54 } | 54 } |
55 | 55 |
56 static void Audio_DeleteDevice(SDL_AudioDevice *device) | 56 static void Audio_DeleteDevice(SDL_AudioDevice *device) |
57 { | 57 { |
58 free(device->hidden); | 58 SDL_free(device->hidden); |
59 free(device); | 59 SDL_free(device); |
60 } | 60 } |
61 | 61 |
62 static SDL_AudioDevice *Audio_CreateDevice(int devindex) | 62 static SDL_AudioDevice *Audio_CreateDevice(int devindex) |
63 { | 63 { |
64 SDL_AudioDevice *this; | 64 SDL_AudioDevice *this; |
65 | 65 |
66 /* Initialize all variables that we clean on shutdown */ | 66 /* Initialize all variables that we clean on shutdown */ |
67 this = (SDL_AudioDevice *)malloc(sizeof(SDL_AudioDevice)); | 67 this = (SDL_AudioDevice *)SDL_malloc(sizeof(SDL_AudioDevice)); |
68 if ( this ) { | 68 if ( this ) { |
69 memset(this, 0, (sizeof *this)); | 69 SDL_memset(this, 0, (sizeof *this)); |
70 this->hidden = (struct SDL_PrivateAudioData *) | 70 this->hidden = (struct SDL_PrivateAudioData *) |
71 malloc((sizeof *this->hidden)); | 71 SDL_malloc((sizeof *this->hidden)); |
72 } | 72 } |
73 if ( (this == NULL) || (this->hidden == NULL) ) { | 73 if ( (this == NULL) || (this->hidden == NULL) ) { |
74 SDL_OutOfMemory(); | 74 SDL_OutOfMemory(); |
75 if ( this ) { | 75 if ( this ) { |
76 free(this); | 76 SDL_free(this); |
77 } | 77 } |
78 return(0); | 78 return(0); |
79 } | 79 } |
80 memset(this->hidden, 0, (sizeof *this->hidden)); | 80 SDL_memset(this->hidden, 0, (sizeof *this->hidden)); |
81 | 81 |
82 /* Set the function pointers */ | 82 /* Set the function pointers */ |
83 this->OpenAudio = DIB_OpenAudio; | 83 this->OpenAudio = DIB_OpenAudio; |
84 this->ThreadInit = DIB_ThreadInit; | 84 this->ThreadInit = DIB_ThreadInit; |
85 this->WaitAudio = DIB_WaitAudio; | 85 this->WaitAudio = DIB_WaitAudio; |
123 char errbuf[MAXERRORLENGTH]; | 123 char errbuf[MAXERRORLENGTH]; |
124 #ifdef _WIN32_WCE | 124 #ifdef _WIN32_WCE |
125 wchar_t werrbuf[MAXERRORLENGTH]; | 125 wchar_t werrbuf[MAXERRORLENGTH]; |
126 #endif | 126 #endif |
127 | 127 |
128 snprintf(errbuf, SDL_arraysize(errbuf), "%s: ", function); | 128 SDL_snprintf(errbuf, SDL_arraysize(errbuf), "%s: ", function); |
129 len = strlen(errbuf); | 129 len = SDL_strlen(errbuf); |
130 | 130 |
131 #ifdef _WIN32_WCE | 131 #ifdef _WIN32_WCE |
132 /* UNICODE version */ | 132 /* UNICODE version */ |
133 waveOutGetErrorText(code, werrbuf, MAXERRORLENGTH-len); | 133 waveOutGetErrorText(code, werrbuf, MAXERRORLENGTH-len); |
134 WideCharToMultiByte(CP_ACP,0,werrbuf,-1,errbuf+len,MAXERRORLENGTH-len,NULL,NULL); | 134 WideCharToMultiByte(CP_ACP,0,werrbuf,-1,errbuf+len,MAXERRORLENGTH-len,NULL,NULL); |
211 wavebuf[i].dwUser = 0xFFFF; | 211 wavebuf[i].dwUser = 0xFFFF; |
212 } | 212 } |
213 } | 213 } |
214 /* Free raw mixing buffer */ | 214 /* Free raw mixing buffer */ |
215 if ( mixbuf != NULL ) { | 215 if ( mixbuf != NULL ) { |
216 free(mixbuf); | 216 SDL_free(mixbuf); |
217 mixbuf = NULL; | 217 mixbuf = NULL; |
218 } | 218 } |
219 } | 219 } |
220 | 220 |
221 int DIB_OpenAudio(_THIS, SDL_AudioSpec *spec) | 221 int DIB_OpenAudio(_THIS, SDL_AudioSpec *spec) |
230 for ( i = 0; i < NUM_BUFFERS; ++i ) | 230 for ( i = 0; i < NUM_BUFFERS; ++i ) |
231 wavebuf[i].dwUser = 0xFFFF; | 231 wavebuf[i].dwUser = 0xFFFF; |
232 mixbuf = NULL; | 232 mixbuf = NULL; |
233 | 233 |
234 /* Set basic WAVE format parameters */ | 234 /* Set basic WAVE format parameters */ |
235 memset(&waveformat, 0, sizeof(waveformat)); | 235 SDL_memset(&waveformat, 0, sizeof(waveformat)); |
236 waveformat.wFormatTag = WAVE_FORMAT_PCM; | 236 waveformat.wFormatTag = WAVE_FORMAT_PCM; |
237 | 237 |
238 /* Determine the audio parameters from the AudioSpec */ | 238 /* Determine the audio parameters from the AudioSpec */ |
239 switch ( spec->format & 0xFF ) { | 239 switch ( spec->format & 0xFF ) { |
240 case 8: | 240 case 8: |
297 SDL_SetError("Couldn't create semaphore"); | 297 SDL_SetError("Couldn't create semaphore"); |
298 return(-1); | 298 return(-1); |
299 } | 299 } |
300 | 300 |
301 /* Create the sound buffers */ | 301 /* Create the sound buffers */ |
302 mixbuf = (Uint8 *)malloc(NUM_BUFFERS*spec->size); | 302 mixbuf = (Uint8 *)SDL_malloc(NUM_BUFFERS*spec->size); |
303 if ( mixbuf == NULL ) { | 303 if ( mixbuf == NULL ) { |
304 SDL_SetError("Out of memory"); | 304 SDL_SetError("Out of memory"); |
305 return(-1); | 305 return(-1); |
306 } | 306 } |
307 for ( i = 0; i < NUM_BUFFERS; ++i ) { | 307 for ( i = 0; i < NUM_BUFFERS; ++i ) { |
308 memset(&wavebuf[i], 0, sizeof(wavebuf[i])); | 308 SDL_memset(&wavebuf[i], 0, sizeof(wavebuf[i])); |
309 wavebuf[i].lpData = (LPSTR) &mixbuf[i*spec->size]; | 309 wavebuf[i].lpData = (LPSTR) &mixbuf[i*spec->size]; |
310 wavebuf[i].dwBufferLength = spec->size; | 310 wavebuf[i].dwBufferLength = spec->size; |
311 wavebuf[i].dwFlags = WHDR_DONE; | 311 wavebuf[i].dwFlags = WHDR_DONE; |
312 result = waveOutPrepareHeader(sound, &wavebuf[i], | 312 result = waveOutPrepareHeader(sound, &wavebuf[i], |
313 sizeof(wavebuf[i])); | 313 sizeof(wavebuf[i])); |