Skip to contentSkip to conversation

Small cosmetic patch to alsa-oss

PATCH Adam Tla/lka 1 participant 1 message Feb 26, 2004

lore
Share & tools
lore
#0 lore raw

Welcome,

try this patch.
I observe that quake3 with this patch works with aoss.

Regards

Signature · 4 lines
Adam Tla/lka      mailto:[email protected]    ^v^ ^v^ ^v^
System  & Network Administration Group           ~~~~~~
Computer Center,  Gdansk University of Technology, Poland
PGP public key:   finger [email protected]
alsa-oss/alsa/alsa-oss.c +9 -23
diff -ru alsa-20040226-orig/alsa-oss/alsa/alsa-oss.c alsa-20040226/alsa-oss/alsa/alsa-oss.c
@@ -196,10 +196,8 @@
 	if (!strncmp(file, "/dev/dsp", 8) ||
 	    !strncmp(file, "/dev/adsp", 9) ||
 	    !strncmp(file, "/dev/audio", 10)) {
-		fd = lib_oss_pcm_open(file, oflag);
-		if (fd >= 0) {
-			fds[fd] = calloc(sizeof(fd_t), 1);
-			if (fds[fd] == NULL) {
+		if ((fd = lib_oss_pcm_open(file, oflag)) >= 0) {
+			if (!(fds[fd] = calloc(sizeof(fd_t), 1))) {
 				ops[FD_OSS_DSP].close(fd);
 				errno = ENOMEM;
 				return -1;
@@ -209,10 +207,8 @@
 			poll_fds_add += lib_oss_pcm_poll_fds(fd);
 		}
 	} else if (!strncmp(file, "/dev/mixer", 10)) {
-		fd = lib_oss_mixer_open(file, oflag);
-		if (fd >= 0) {
-			fds[fd] = calloc(sizeof(fd_t), 1);
-			if (fds[fd] == NULL) {
+		if ((fd = lib_oss_mixer_open(file, oflag)) >= 0) {
+			if (!(fds[fd] = calloc(sizeof(fd_t), 1))) {
 				ops[FD_OSS_MIXER].close(fd);
 				errno = ENOMEM;
 				return -1;
@@ -220,11 +216,8 @@
 			fds[fd]->class = FD_OSS_MIXER;
 			fds[fd]->oflags = oflag;
 		}
-	} else {
-		fd = _open(file, oflag, mode);
-		if (fd >= 0)
+	} else if ((fd = _open(file, oflag, mode)) >= 0)
 			assert(fds[fd] == NULL);
-	}
 	return fd;
 }
 
@@ -671,18 +664,11 @@
 
 static void initialize()
 {
-	char *s = getenv("ALSA_OSS_WRAPPER");
-	if (s == NULL)
-		return;
-	s = getenv("ALSA_OSS_DEBUG");
-	if (s)
-		alsa_oss_debug = 1;
-	open_max = sysconf(_SC_OPEN_MAX);
-	if (open_max < 0)
-		exit(1);
-	fds = calloc(open_max, sizeof(*fds));
-	if (!fds)
+	if ((open_max = sysconf(_SC_OPEN_MAX)) < 0 ||
+	    !(fds = calloc(open_max, sizeof(*fds))))
 		exit(1);
+		if (getenv("ALSA_OSS_DEBUG"))
+		alsa_oss_debug = 1;
 	_open = dlsym(RTLD_NEXT, "open");
 	_close = dlsym(RTLD_NEXT, "close");
 	_write = dlsym(RTLD_NEXT, "write");
alsa-oss/alsa/pcm.c +141 -262

780 lines not on this page · raw message