| 188 |
196 |
| 189 return 1; |
197 return 1; |
| 190 } |
198 } |
| 191 |
199 |
| 192 #endif |
200 #endif |
| |
201 |
| |
202 #ifdef ARTSC_SOUND |
| |
203 |
| |
204 static int play_artsc(unsigned char *data, int size) |
| |
205 { |
| |
206 arts_stream_t stream; |
| |
207 guint16* lineardata; |
| |
208 int result = 1; |
| |
209 int error; |
| |
210 int i; |
| |
211 |
| |
212 lineardata = g_malloc(size * 2); |
| |
213 |
| |
214 for (i = 0; i < size; i++) { |
| |
215 lineardata[i] = _af_ulaw2linear(data[i]); |
| |
216 } |
| |
217 |
| |
218 stream = arts_play_stream(8012, 16, 1, "gaim"); |
| |
219 |
| |
220 error = arts_write(stream, lineardata, size); |
| |
221 if (error < 0) { |
| |
222 result = 0; |
| |
223 } |
| |
224 |
| |
225 arts_close_stream(stream); |
| |
226 |
| |
227 g_free(lineardata); |
| |
228 |
| |
229 arts_free(); |
| |
230 |
| |
231 return result; |
| |
232 } |
| |
233 |
| |
234 static int can_play_artsc() |
| |
235 { |
| |
236 int error; |
| |
237 |
| |
238 error = artsc_init(); |
| |
239 if (error < 0) |
| |
240 return 0; |
| |
241 |
| |
242 return 1; |
| |
243 } |
| |
244 |
| |
245 static int play_artsc_file(char *file) |
| |
246 { |
| |
247 struct stat stat_buf; |
| |
248 unsigned char* buf = NULL; |
| |
249 int result = 0; |
| |
250 int fd = -1; |
| |
251 |
| |
252 fd = open(file, O_RDONLY); |
| |
253 if (fd < 0) |
| |
254 goto out; |
| |
255 |
| |
256 if (!can_play_artsc()) |
| |
257 goto out; |
| |
258 |
| |
259 if (fstat(fd, &stat_buf)) |
| |
260 goto out; |
| |
261 |
| |
262 if (!stat_buf.st_size) |
| |
263 goto out; |
| |
264 |
| |
265 buf = g_malloc(stat_buf.st_size); |
| |
266 if (!buf) |
| |
267 goto out; |
| |
268 |
| |
269 if (read(fd, buf, stat_buf.st_size) < 0) |
| |
270 goto out; |
| |
271 |
| |
272 result = play_artsc(buf, stat_buf.st_size); |
| |
273 |
| |
274 out: |
| |
275 if (buf) g_free(buf); |
| |
276 if (fd != -1) close(fd); |
| |
277 return result; |
| |
278 } |
| |
279 |
| |
280 #endif /* ARTSC_SOUND */ |
| 193 |
281 |
| 194 #ifdef NAS_SOUND |
282 #ifdef NAS_SOUND |
| 195 |
283 |
| 196 char nas_server[] = "localhost"; |
284 char nas_server[] = "localhost"; |
| 197 AuServer *nas_serv = NULL; |
285 AuServer *nas_serv = NULL; |
| 363 if (play_esd(data, size)) |
451 if (play_esd(data, size)) |
| 364 _exit(0); |
452 _exit(0); |
| 365 } |
453 } |
| 366 #endif |
454 #endif |
| 367 |
455 |
| |
456 #ifdef ARTSC_SOUND |
| |
457 /* ArtsC is the new second choice. */ |
| |
458 if (can_play_artsc()) { |
| |
459 if (play_artsc(data, size)) |
| |
460 _exit(0); |
| |
461 } |
| |
462 #endif |
| |
463 |
| 368 #ifdef NAS_SOUND |
464 #ifdef NAS_SOUND |
| 369 /* NAS is our second choice setup. */ |
465 /* NAS is our second choice setup. */ |
| 370 if (can_play_nas()) { |
466 if (can_play_nas()) { |
| 371 if (play_nas(data, size)) |
467 if (play_nas(data, size)) |
| 372 _exit(0); |
468 _exit(0); |