Mercurial > pidgin
diff 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 |
line wrap: on
line diff
--- a/src/sound.c Mon Nov 20 08:35:25 2000 +0000 +++ b/src/sound.c Mon Nov 20 10:37:40 2000 +0000 @@ -97,14 +97,18 @@ return; } fstat(fd, &info); + if (info.st_size < 24) + return; buf = malloc(info.st_size + 1); read(fd, buf, 24); read(fd, buf, info.st_size - 24); close(fd); fd = open("/dev/audio", O_WRONLY | O_EXCL); - if (fd < 0) + if (fd < 0) { + free(buf); return; + } write(fd, buf, info.st_size - 24); free(buf); close(fd); @@ -271,6 +275,31 @@ return 0; } +static int play_nas_file(char *file) +{ + struct stat stat_buf; + char *buf; + int ret; + int fd = open(file, O_RDONLY); + if (fd <= 0) + return 0; + + if (!can_play_nas()) + return 0; + + if (stat(file, &stat_buf)) + return 0; + + if (!stat_buf.st_size) + return 0; + + buf = malloc(stat_buf.st_size); + read(fd, buf, stat_buf.st_size); + ret = play_nas(buf, stat_buf.st_size); + free(buf); + return ret; +} + #endif void play_file(char *filename) { @@ -296,7 +325,10 @@ _exit(0); #endif - /* FIXME : NAS (does anyone use this?) */ +#ifdef NAS_SOUND + if (play_nas_file(filenae)) + _exit(0); +#endif if (can_play_audio()) { play_audio_file(filename);
