comparison src/audio/SDL_audiodev.c @ 2060:866052b01ee5

indent is evil
author Sam Lantinga <slouken@libsdl.org>
date Sat, 28 Oct 2006 16:48:03 +0000
parents 5f6550e5184f
children 771bd3389e3a
comparison
equal deleted inserted replaced
2059:4685ccd33d0e 2060:866052b01ee5
45 #ifndef _PATH_DEV_AUDIO 45 #ifndef _PATH_DEV_AUDIO
46 #define _PATH_DEV_AUDIO "/dev/audio" 46 #define _PATH_DEV_AUDIO "/dev/audio"
47 #endif 47 #endif
48 48
49 static inline void 49 static inline void
50 test_device(const char *fname, int flags, int (*test)(int fd), 50 test_device(const char *fname, int flags, int (*test) (int fd),
51 char ***devices, int *devCount) 51 char ***devices, int *devCount)
52 { 52 {
53 struct stat sb; 53 struct stat sb;
54 if ( (stat(fname, &sb) == 0) && (S_ISCHR(sb.st_mode)) ) { 54 if ((stat(fname, &sb) == 0) && (S_ISCHR(sb.st_mode))) {
55 int audio_fd = open(fname, flags, 0); 55 int audio_fd = open(fname, flags, 0);
56 if ( (audio_fd >= 0) && (test(audio_fd)) ) { 56 if ((audio_fd >= 0) && (test(audio_fd))) {
57 void *p = SDL_realloc(*devices, ((*devCount)+1) * sizeof (char *)); 57 void *p =
58 SDL_realloc(*devices, ((*devCount) + 1) * sizeof(char *));
58 if (p != NULL) { 59 if (p != NULL) {
59 size_t len = strlen(fname) + 1; 60 size_t len = strlen(fname) + 1;
60 char *str = (char *) SDL_malloc(len); 61 char *str = (char *) SDL_malloc(len);
61 *devices = (char **) p; 62 *devices = (char **) p;
62 if (str != NULL) { 63 if (str != NULL) {
73 SDL_FreeUnixAudioDevices(char ***devices, int *devCount) 74 SDL_FreeUnixAudioDevices(char ***devices, int *devCount)
74 { 75 {
75 int i = *devCount; 76 int i = *devCount;
76 if ((i > 0) && (*devices != NULL)) { 77 if ((i > 0) && (*devices != NULL)) {
77 while (i--) { 78 while (i--) {
78 SDL_free( (*devices)[*devCount] ); 79 SDL_free((*devices)[*devCount]);
79 } 80 }
80 } 81 }
81 82
82 if (*devices != NULL) { 83 if (*devices != NULL) {
83 SDL_free(*devices); 84 SDL_free(*devices);
92 { 93 {
93 return 1; 94 return 1;
94 } 95 }
95 96
96 void 97 void
97 SDL_EnumUnixAudioDevices(int flags, int classic, int (*test)(int fd), 98 SDL_EnumUnixAudioDevices(int flags, int classic, int (*test) (int fd),
98 char ***devices, int *devCount) 99 char ***devices, int *devCount)
99 { 100 {
100 const char *audiodev; 101 const char *audiodev;
101 char audiopath[1024]; 102 char audiopath[1024];
102 103