Mercurial > pidgin
comparison src/sound.c @ 1109:c73736fa0b7c
[gaim-migrate @ 1119]
Auto-Away, courtesy BMiller. damn cool. i'm impressed. also minor touch-ups, mostly to indicate what all the FIXME's mean.
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Mon, 20 Nov 2000 10:37:40 +0000 |
parents | d50d3abb9eb7 |
children | 0baf39dc5437 |
comparison
equal
deleted
inserted
replaced
1108:cb338aa38e78 | 1109:c73736fa0b7c |
---|---|
95 int fd = open(file, O_RDONLY); | 95 int fd = open(file, O_RDONLY); |
96 if (fd <= 0) { | 96 if (fd <= 0) { |
97 return; | 97 return; |
98 } | 98 } |
99 fstat(fd, &info); | 99 fstat(fd, &info); |
100 if (info.st_size < 24) | |
101 return; | |
100 buf = malloc(info.st_size + 1); | 102 buf = malloc(info.st_size + 1); |
101 read(fd, buf, 24); | 103 read(fd, buf, 24); |
102 read(fd, buf, info.st_size - 24); | 104 read(fd, buf, info.st_size - 24); |
103 close(fd); | 105 close(fd); |
104 | 106 |
105 fd = open("/dev/audio", O_WRONLY | O_EXCL); | 107 fd = open("/dev/audio", O_WRONLY | O_EXCL); |
106 if (fd < 0) | 108 if (fd < 0) { |
109 free(buf); | |
107 return; | 110 return; |
111 } | |
108 write(fd, buf, info.st_size - 24); | 112 write(fd, buf, info.st_size - 24); |
109 free(buf); | 113 free(buf); |
110 close(fd); | 114 close(fd); |
111 } | 115 } |
112 | 116 |
269 if ((nas_serv = AuOpenServer(NULL, 0, NULL, 0, NULL, NULL))) | 273 if ((nas_serv = AuOpenServer(NULL, 0, NULL, 0, NULL, NULL))) |
270 return 1; | 274 return 1; |
271 return 0; | 275 return 0; |
272 } | 276 } |
273 | 277 |
278 static int play_nas_file(char *file) | |
279 { | |
280 struct stat stat_buf; | |
281 char *buf; | |
282 int ret; | |
283 int fd = open(file, O_RDONLY); | |
284 if (fd <= 0) | |
285 return 0; | |
286 | |
287 if (!can_play_nas()) | |
288 return 0; | |
289 | |
290 if (stat(file, &stat_buf)) | |
291 return 0; | |
292 | |
293 if (!stat_buf.st_size) | |
294 return 0; | |
295 | |
296 buf = malloc(stat_buf.st_size); | |
297 read(fd, buf, stat_buf.st_size); | |
298 ret = play_nas(buf, stat_buf.st_size); | |
299 free(buf); | |
300 return ret; | |
301 } | |
302 | |
274 #endif | 303 #endif |
275 | 304 |
276 void play_file(char *filename) { | 305 void play_file(char *filename) { |
277 int pid; | 306 int pid; |
278 | 307 |
294 #ifdef ESD_SOUND | 323 #ifdef ESD_SOUND |
295 if (play_esd_file(filename)) | 324 if (play_esd_file(filename)) |
296 _exit(0); | 325 _exit(0); |
297 #endif | 326 #endif |
298 | 327 |
299 /* FIXME : NAS (does anyone use this?) */ | 328 #ifdef NAS_SOUND |
329 if (play_nas_file(filenae)) | |
330 _exit(0); | |
331 #endif | |
300 | 332 |
301 if (can_play_audio()) { | 333 if (can_play_audio()) { |
302 play_audio_file(filename); | 334 play_audio_file(filename); |
303 _exit(0); | 335 _exit(0); |
304 } | 336 } |