[MPlayer-dev-eng] [PATCH] -ao alsa9:hw:0,0 fix

Wojtek Kaniewski wojtekka at bydg.pdi.net
Sat Jun 7 23:46:34 CEST 2003


sorry for so late reply, but i didn't have access to the net last week.  

On Fri, 30 May 2003, Alex Beregszaszi wrote:
> > i could be wrong but it seems that with -ao fallback code it's
> > impossible to specify alsa9 devices like "hw:0,1", because mplayer
> > treats "1" as secondary ao. i have made two simple patches -- first
> > one changes all points followed by a number to commas in alsa device
> > name, so it's possible to use hw:0,1 by "-ao alsa9:hw:0.1". second
> > patch adds an example to the manpage.
> 
> I would use strrchr() instead,

okay.

> and don't forget to check if the dot
> isn't the last char in the string, to avoid segfaults.

it checks if the next character is a digit and that's enough, because
'\0' isn't.

regards,
wojtek

-------------- next part --------------
--- libao2/ao_alsa9.c.orig	Fri May  2 13:36:40 2003
+++ libao2/ao_alsa9.c	Fri May  2 14:12:48 2003
@@ -317,8 +317,12 @@
 	  }
 	  else if (strcmp(*(token_str+i3), "hw") == 0) {
 	    if ((i3 < i2-1) && (strcmp(*(token_str+i3+1), "noblock") != 0) && (strcmp(*(token_str+i3+1), "mmap") != 0)) {
+              char *tmp;
+
 	      alsa_device = alloca(ALSA_DEVICE_SIZE);
 	      snprintf(alsa_device, ALSA_DEVICE_SIZE, "hw:%s", *(token_str+(i3+1)));
+	      if ((tmp = strrchr(alsa_device, '.')) && isdigit(*(tmp+1)))
+                *tmp = ',';
 	      device_set = 1;
 	    }
 		else {
@@ -421,9 +425,9 @@
 	printf("alsa-help: available options are:\n");
 	printf("           mmap: sets mmap-mode\n");
 	printf("           noblock: sets noblock-mode\n");
-	printf("           device-name: sets device name\n");
-	printf("           example -ao alsa9:mmap:noblock:hw:0,3 sets noblock-mode,\n");
-	printf("           mmap-mode and the device-name as first card third device\n");
+	printf("           device-name: sets device name (change comma to point)\n");
+	printf("           example -ao alsa9:mmap:noblock:hw:0.3 sets noblock-mode,\n");
+	printf("           mmap-mode and the device-name as first card fourth device\n");
 	return(0);
       } else {
 		printf("alsa-init: soundcard set to %s\n", alsa_device);


More information about the MPlayer-dev-eng mailing list