comparison src/audio/SDL_audiodev.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
53 const char *audiodev; 53 const char *audiodev;
54 int audio_fd; 54 int audio_fd;
55 char audiopath[1024]; 55 char audiopath[1024];
56 56
57 /* Figure out what our audio device is */ 57 /* Figure out what our audio device is */
58 if ( ((audiodev=getenv("SDL_PATH_DSP")) == NULL) && 58 if ( ((audiodev=SDL_getenv("SDL_PATH_DSP")) == NULL) &&
59 ((audiodev=getenv("AUDIODEV")) == NULL) ) { 59 ((audiodev=SDL_getenv("AUDIODEV")) == NULL) ) {
60 if ( classic ) { 60 if ( classic ) {
61 audiodev = _PATH_DEV_AUDIO; 61 audiodev = _PATH_DEV_AUDIO;
62 } else { 62 } else {
63 struct stat sb; 63 struct stat sb;
64 64
72 } 72 }
73 } 73 }
74 audio_fd = open(audiodev, flags, 0); 74 audio_fd = open(audiodev, flags, 0);
75 75
76 /* If the first open fails, look for other devices */ 76 /* If the first open fails, look for other devices */
77 if ( (audio_fd < 0) && (strlen(audiodev) < (sizeof(audiopath)-3)) ) { 77 if ( (audio_fd < 0) && (SDL_strlen(audiodev) < (sizeof(audiopath)-3)) ) {
78 int exists, instance; 78 int exists, instance;
79 struct stat sb; 79 struct stat sb;
80 80
81 instance = 1; 81 instance = 1;
82 do { /* Don't use errno ENOENT - it may not be thread-safe */ 82 do { /* Don't use errno ENOENT - it may not be thread-safe */
88 } 88 }
89 } while ( exists && (audio_fd < 0) ); 89 } while ( exists && (audio_fd < 0) );
90 audiodev = audiopath; 90 audiodev = audiopath;
91 } 91 }
92 if ( path != NULL ) { 92 if ( path != NULL ) {
93 strncpy(path, audiodev, maxlen); 93 SDL_strncpy(path, audiodev, maxlen);
94 path[maxlen-1] = '\0'; 94 path[maxlen-1] = '\0';
95 } 95 }
96 return(audio_fd); 96 return(audio_fd);
97 } 97 }
98 98
128 { 128 {
129 const char *audiodev; 129 const char *audiodev;
130 int audio_fd; 130 int audio_fd;
131 131
132 /* Figure out what our audio device is */ 132 /* Figure out what our audio device is */
133 if ((audiodev=getenv("SDL_PATH_DSP")) == NULL) { 133 if ((audiodev=SDL_getenv("SDL_PATH_DSP")) == NULL) {
134 audiodev=getenv("AUDIODEV"); 134 audiodev=SDL_getenv("AUDIODEV");
135 } 135 }
136 if ( audiodev == NULL ) { 136 if ( audiodev == NULL ) {
137 return -1; 137 return -1;
138 } 138 }
139 audio_fd = open(audiodev, flags, 0); 139 audio_fd = open(audiodev, flags, 0);
140 if ( path != NULL ) { 140 if ( path != NULL ) {
141 strncpy(path, audiodev, maxlen); 141 SDL_strncpy(path, audiodev, maxlen);
142 path[maxlen-1] = '\0'; 142 path[maxlen-1] = '\0';
143 } 143 }
144 return audio_fd; 144 return audio_fd;
145 } 145 }
146 146
166 166
167 if ( stat(audiopath, &sb) == 0 ) { 167 if ( stat(audiopath, &sb) == 0 ) {
168 audio_fd = open(audiopath, flags, 0); 168 audio_fd = open(audiopath, flags, 0);
169 if ( audio_fd > 0 ) { 169 if ( audio_fd > 0 ) {
170 if ( path != NULL ) { 170 if ( path != NULL ) {
171 strncpy( path, audiopath, maxlen ); 171 SDL_strncpy( path, audiopath, maxlen );
172 path[maxlen-1] = '\0'; 172 path[maxlen-1] = '\0';
173 } 173 }
174 return audio_fd; 174 return audio_fd;
175 } 175 }
176 } 176 }