changeset 655:6ba20a0089d8

[gaim-migrate @ 665] added another check to can_play_esd (or whatever) to make sure /dev/dsp is available committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Thu, 10 Aug 2000 05:02:01 +0000
parents ea811c6dd3e0
children 732ee4f6f541
files src/sound.c
diffstat 1 files changed, 19 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/src/sound.c	Thu Aug 10 04:13:46 2000 +0000
+++ b/src/sound.c	Thu Aug 10 05:02:01 2000 +0000
@@ -48,6 +48,22 @@
 #include "sounds/Send.h"
 #include "sounds/Receive.h"
 
+static int check_dev(char *dev)
+{
+	struct stat stat_buf;
+	uid_t user = getuid();
+	gid_t group = getgid(); 
+	if (stat(dev, &stat_buf))
+		return 0;
+	if (user == stat_buf.st_uid && stat_buf.st_mode & S_IWUSR)
+		return 1;
+	if (group == stat_buf.st_gid && stat_buf.st_mode & S_IWGRP)
+		return 1;
+	if (stat_buf.st_mode & S_IWOTH)
+		return 1;
+	return 0;
+}
+
 
 static void play_audio(char *data, int size)
 {
@@ -62,18 +78,7 @@
 
 static int can_play_audio()
 {
-	struct stat stat_buf;
-	uid_t user = getuid();
-	gid_t group = getgid(); 
-	if (stat("/dev/audio", &stat_buf))
-		return 0;
-	if (user == stat_buf.st_uid && stat_buf.st_mode & S_IWUSR)
-		return 1;
-	if (group == stat_buf.st_gid && stat_buf.st_mode & S_IWGRP)
-		return 1;
-	if (stat_buf.st_mode & S_IWOTH)
-		return 1;
-	return 0;
+	return check_dev("/dev/audio");
 }
 
 
@@ -135,6 +140,8 @@
 static int can_play_esd()
 {
 	esd_format_t format = ESD_BITS16 | ESD_STREAM | ESD_PLAY | ESD_MONO;
+
+	if (!check_dev("/dev/dsp")) return 0;
 	
         esd_fd = esd_play_stream(format, 8012, NULL, "gaim");