comparison src/sound.c @ 79:bfdc427b936d

[gaim-migrate @ 89] I'll save time and just post the email :-) Summary of changes: * Misc malloc/free cleanups, use g_malloc more places and other small stuff (e.g. lineardata not being freed in the error case in sound.c) * Misc signed/unsigned cleanups (use size_t more often) * read() can return -1 at any point, check return values more rigorously (read_rv variables used for this) * In can_play_audio, stat requires a pointer to an allocated stat_buf (the address of an automatic variable) * escape_text needs a buffer at least 4 times the size of the text being passed in (not 2 times); I can force core dumps with lots of newlines otherwise * There's a debug statement in netscape_command (browser.c) that was printf("Hello%d\n"); with no int for the %d; I threw in a getppid(), but the statement should probably come out eventually. Thanks, G Sumner Hayes! committer: Tailor Script <tailor@pidgin.im>
author Rob Flynn <gaim@robflynn.com>
date Wed, 05 Apr 2000 05:34:08 +0000
parents b1d7336cba85
children 05077cb276d4
comparison
equal deleted inserted replaced
78:66c5a24b62ec 79:bfdc427b936d
58 close(fd); 58 close(fd);
59 } 59 }
60 60
61 static int can_play_audio() 61 static int can_play_audio()
62 { 62 {
63 struct stat *stat_buf; 63 struct stat stat_buf;
64 uid_t user = getuid(); 64 uid_t user = getuid();
65 gid_t group = getgid(); 65 gid_t group = getgid();
66 if (stat("/dev/audio", stat_buf)) 66 if (stat("/dev/audio", &stat_buf))
67 return 0; 67 return 0;
68 if (user == stat_buf->st_uid && stat_buf->st_mode & S_IWUSR) 68 if (user == stat_buf.st_uid && stat_buf.st_mode & S_IWUSR)
69 return 1; 69 return 1;
70 if (group == stat_buf->st_gid && stat_buf->st_mode & S_IWGRP) 70 if (group == stat_buf.st_gid && stat_buf.st_mode & S_IWGRP)
71 return 1; 71 return 1;
72 if (stat_buf->st_mode & S_IWOTH) 72 if (stat_buf.st_mode & S_IWOTH)
73 return 1; 73 return 1;
74 return 0; 74 return 0;
75 } 75 }
76 76
77 77
112 112
113 static int play_esd(unsigned char *data, int size) 113 static int play_esd(unsigned char *data, int size)
114 { 114 {
115 int fd, i; 115 int fd, i;
116 esd_format_t format = ESD_BITS16 | ESD_STREAM | ESD_PLAY | ESD_MONO; 116 esd_format_t format = ESD_BITS16 | ESD_STREAM | ESD_PLAY | ESD_MONO;
117 guint16 *lineardata = g_malloc(size * 2); 117 guint16 *lineardata;
118 118
119 119
120 fd = esd_play_stream(format, 8012, NULL, "gaim"); 120 fd = esd_play_stream(format, 8012, NULL, "gaim");
121 121
122 if (fd < 0) 122 if (fd < 0) {
123 return 0; 123 return 0;
124 }
125
126 lineardata = g_malloc(size * 2);
124 127
125 for (i=0; i<size; i++) 128 for (i=0; i<size; i++)
126 lineardata[i] = _af_ulaw2linear(data[i]); 129 lineardata[i] = _af_ulaw2linear(data[i]);
127 130
128 write(fd, lineardata, size * 2); 131 write(fd, lineardata, size * 2);