comparison src/audio/disk/SDL_diskaudio.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 c9b51268668f
children 604d73db6802
comparison
equal deleted inserted replaced
1335:c39265384763 1336:3692456e7b0f
60 static Uint8 *DISKAUD_GetAudioBuf(_THIS); 60 static Uint8 *DISKAUD_GetAudioBuf(_THIS);
61 static void DISKAUD_CloseAudio(_THIS); 61 static void DISKAUD_CloseAudio(_THIS);
62 62
63 static const char *DISKAUD_GetOutputFilename(void) 63 static const char *DISKAUD_GetOutputFilename(void)
64 { 64 {
65 const char *envr = getenv(DISKENVR_OUTFILE); 65 const char *envr = SDL_getenv(DISKENVR_OUTFILE);
66 return((envr != NULL) ? envr : DISKDEFAULT_OUTFILE); 66 return((envr != NULL) ? envr : DISKDEFAULT_OUTFILE);
67 } 67 }
68 68
69 /* Audio driver bootstrap functions */ 69 /* Audio driver bootstrap functions */
70 static int DISKAUD_Available(void) 70 static int DISKAUD_Available(void)
73 int fd; 73 int fd;
74 int available; 74 int available;
75 int exists = 0; 75 int exists = 0;
76 struct stat statbuf; 76 struct stat statbuf;
77 const char *fname = DISKAUD_GetOutputFilename(); 77 const char *fname = DISKAUD_GetOutputFilename();
78 const char *envr = getenv("SDL_AUDIODRIVER"); 78 const char *envr = SDL_getenv("SDL_AUDIODRIVER");
79 available = 0; 79 available = 0;
80 80
81 if ((envr) && (strcmp(envr, DISKAUD_DRIVER_NAME) == 0)) { 81 if ((envr) && (SDL_strcmp(envr, DISKAUD_DRIVER_NAME) == 0)) {
82 if (stat(fname, &statbuf) == 0) 82 if (stat(fname, &statbuf) == 0)
83 exists = 1; 83 exists = 1;
84 84
85 fd = open(fname, O_WRONLY | O_CREAT | O_APPEND, S_IRUSR | S_IWUSR); 85 fd = open(fname, O_WRONLY | O_CREAT | O_APPEND, S_IRUSR | S_IWUSR);
86 if ( fd != -1 ) { 86 if ( fd != -1 ) {
91 } 91 }
92 } 92 }
93 } 93 }
94 return(available); 94 return(available);
95 #else 95 #else
96 const char *envr = getenv("SDL_AUDIODRIVER"); 96 const char *envr = SDL_getenv("SDL_AUDIODRIVER");
97 if ((envr) && (strcmp(envr, DISKAUD_DRIVER_NAME) == 0)) { 97 if ((envr) && (SDL_strcmp(envr, DISKAUD_DRIVER_NAME) == 0)) {
98 return(1); 98 return(1);
99 } 99 }
100 100
101 return(0); 101 return(0);
102 #endif 102 #endif
103 } 103 }
104 104
105 static void DISKAUD_DeleteDevice(SDL_AudioDevice *device) 105 static void DISKAUD_DeleteDevice(SDL_AudioDevice *device)
106 { 106 {
107 free(device->hidden); 107 SDL_free(device->hidden);
108 free(device); 108 SDL_free(device);
109 } 109 }
110 110
111 static SDL_AudioDevice *DISKAUD_CreateDevice(int devindex) 111 static SDL_AudioDevice *DISKAUD_CreateDevice(int devindex)
112 { 112 {
113 SDL_AudioDevice *this; 113 SDL_AudioDevice *this;
114 const char *envr; 114 const char *envr;
115 115
116 /* Initialize all variables that we clean on shutdown */ 116 /* Initialize all variables that we clean on shutdown */
117 this = (SDL_AudioDevice *)malloc(sizeof(SDL_AudioDevice)); 117 this = (SDL_AudioDevice *)SDL_malloc(sizeof(SDL_AudioDevice));
118 if ( this ) { 118 if ( this ) {
119 memset(this, 0, (sizeof *this)); 119 SDL_memset(this, 0, (sizeof *this));
120 this->hidden = (struct SDL_PrivateAudioData *) 120 this->hidden = (struct SDL_PrivateAudioData *)
121 malloc((sizeof *this->hidden)); 121 SDL_malloc((sizeof *this->hidden));
122 } 122 }
123 if ( (this == NULL) || (this->hidden == NULL) ) { 123 if ( (this == NULL) || (this->hidden == NULL) ) {
124 SDL_OutOfMemory(); 124 SDL_OutOfMemory();
125 if ( this ) { 125 if ( this ) {
126 free(this); 126 SDL_free(this);
127 } 127 }
128 return(0); 128 return(0);
129 } 129 }
130 memset(this->hidden, 0, (sizeof *this->hidden)); 130 SDL_memset(this->hidden, 0, (sizeof *this->hidden));
131 131
132 envr = getenv(DISKENVR_WRITEDELAY); 132 envr = SDL_getenv(DISKENVR_WRITEDELAY);
133 this->hidden->write_delay = (envr) ? atoi(envr) : DISKDEFAULT_WRITEDELAY; 133 this->hidden->write_delay = (envr) ? atoi(envr) : DISKDEFAULT_WRITEDELAY;
134 134
135 /* Set the function pointers */ 135 /* Set the function pointers */
136 this->OpenAudio = DISKAUD_OpenAudio; 136 this->OpenAudio = DISKAUD_OpenAudio;
137 this->WaitAudio = DISKAUD_WaitAudio; 137 this->WaitAudio = DISKAUD_WaitAudio;
214 this->hidden->mixlen = spec->size; 214 this->hidden->mixlen = spec->size;
215 this->hidden->mixbuf = (Uint8 *) SDL_AllocAudioMem(this->hidden->mixlen); 215 this->hidden->mixbuf = (Uint8 *) SDL_AllocAudioMem(this->hidden->mixlen);
216 if ( this->hidden->mixbuf == NULL ) { 216 if ( this->hidden->mixbuf == NULL ) {
217 return(-1); 217 return(-1);
218 } 218 }
219 memset(this->hidden->mixbuf, spec->silence, spec->size); 219 SDL_memset(this->hidden->mixbuf, spec->silence, spec->size);
220 220
221 /* We're ready to rock and roll. :-) */ 221 /* We're ready to rock and roll. :-) */
222 return(0); 222 return(0);
223 } 223 }
224 224