[xiph-commits] r16827 - in trunk/ao/src: . plugins/alsa09

xiphmont at svn.xiph.org xiphmont at svn.xiph.org
Tue Jan 26 21:15:37 PST 2010


Author: xiphmont
Date: 2010-01-26 21:15:37 -0800 (Tue, 26 Jan 2010)
New Revision: 16827

Modified:
   trunk/ao/src/ao_aixs.c
   trunk/ao/src/audio_out.c
   trunk/ao/src/plugins/alsa09/ao_alsa09.c
Log:
More changes to default alsa device selection;
ALSA makes it impossible to know what it's actually doing, and many apps 
that access it directly hold the defaul device open, which multiplexes 
but only in stereo.  Add more warnings such that when sturround playback 
fails, the user knows what actually went wrong (eg, firefox is holding 
'default' open which has locked the playback hardware into stereo-only)



Modified: trunk/ao/src/ao_aixs.c
===================================================================
--- trunk/ao/src/ao_aixs.c	2010-01-27 04:16:24 UTC (rev 16826)
+++ trunk/ao/src/ao_aixs.c	2010-01-27 05:15:37 UTC (rev 16827)
@@ -37,7 +37,7 @@
 
 
 /*
- * default audio device to be used, 
+ * default audio device to be used,
  * possible options:
  * /dev/paud0/1 on PCI machines with the Crystal chipset
  * /dev/baud0/1 on MCA machines with the Crystal chipset
@@ -93,16 +93,16 @@
 
 	internal = (ao_aixs_internal *) malloc(sizeof(ao_aixs_internal));
 
-	if (internal == NULL)	
+	if (internal == NULL)
 		return 0; /* Could not initialize device memory */
-	
+
 	internal->dev = strdup(AO_AIX_DEFAULT_DEV);
-	
+
 	if (internal->dev == NULL) {
 		free(internal);
 		return 0;
 	}
-		
+
 	device->internal = internal;
 
 	return 1; /* Memory alloc successful */
@@ -115,7 +115,7 @@
 
 	if (!strcmp(key, "dev")) {
 		/* Free old string in case "dsp" set twice in options */
-		free(internal->dev); 
+		free(internal->dev);
 		internal->dev = strdup(value);
 	}
 
@@ -126,7 +126,7 @@
 int ao_aixs_open(ao_device *device, ao_sample_format *format)
 {
 	ao_aixs_internal *internal = (ao_aixs_internal *) device->internal;
-	
+
 	audio_init init;
 	audio_control control;
 	audio_change change;
@@ -162,7 +162,7 @@
 	}
 
 	control.ioctl_request = AUDIO_START;
-	control.request_info = NULL; 
+	control.request_info = NULL;
 
 	if (ioctl(internal->fd, AUDIO_CONTROL, &control) < 0) {
 		close(internal->fd);
@@ -175,11 +175,11 @@
 }
 
 
-int ao_aixs_play(ao_device *device, const char *output_samples, 
+int ao_aixs_play(ao_device *device, const char *output_samples,
 		uint_32 num_bytes)
 {
 	ao_aixs_internal *internal = (ao_aixs_internal *) device->internal;
-	
+
 	if (write(internal->fd, output_samples, num_bytes) < 0)
 		return 0;
 	else

Modified: trunk/ao/src/audio_out.c
===================================================================
--- trunk/ao/src/audio_out.c	2010-01-27 04:16:24 UTC (rev 16826)
+++ trunk/ao/src/audio_out.c	2010-01-27 05:15:37 UTC (rev 16827)
@@ -773,7 +773,7 @@
               fprintf(stderr,"\n");
 
             while(count<device->output_channels){
-              int m=0,mm;
+              int m=1,mm;
               char *h=op;
 
               if(*op){
@@ -802,8 +802,8 @@
                           count,mnemonics[m],device->permute_channels[count],
                           mnemonics[mm]);
                 }else{
-                  fprintf(stderr,"Output %d (%s)\t <- %s\n",
-                          count,mnemonics[m],(m==1?"unavailable":"none"));
+                  fprintf(stderr,"Output %d (%s)\t %s\n",
+                          count,mnemonics[m],(m==1?"unmapped":"<- none"));
                 }
               }
               count++;

Modified: trunk/ao/src/plugins/alsa09/ao_alsa09.c
===================================================================
--- trunk/ao/src/plugins/alsa09/ao_alsa09.c	2010-01-27 04:16:24 UTC (rev 16826)
+++ trunk/ao/src/plugins/alsa09/ao_alsa09.c	2010-01-27 05:15:37 UTC (rev 16827)
@@ -358,6 +358,7 @@
 
 	/* Open the ALSA device */
 	internal->cmd = "snd_pcm_open";
+        err=0;
         if(!internal->dev){
           char *tmp=NULL;
           /* we don't try just 'default' as it's a plug device that
@@ -369,28 +370,31 @@
           case 7:
             err = snd_pcm_open(&(internal->pcm_handle), tmp="surround71",
                                SND_PCM_STREAM_PLAYBACK, 0);
+            break;
+          case 4:
+          case 3:
+            err = snd_pcm_open(&(internal->pcm_handle), tmp="surround40",
+                               SND_PCM_STREAM_PLAYBACK, 0);
             if(err==0)break;
-            /* fall through */
           case 6:
           case 5:
-          case 4:
-          case 3:
             err = snd_pcm_open(&(internal->pcm_handle), tmp="surround51",
                                SND_PCM_STREAM_PLAYBACK, 0);
-            if(err==0)break;
-            err = snd_pcm_open(&(internal->pcm_handle), tmp="surround40",
-                               SND_PCM_STREAM_PLAYBACK, 0);
-            if(err==0)break;
-            /* fall through */
+          case 1:
           case 2:
-          case 1:
+            break;
+          }
+
+          if(err){
+            fprintf(stderr,"ERROR: Unable to open ALSA surround device '%s'\n"
+                           "       trying default device...\n",tmp);
+            tmp=NULL;
+          }
+          if(!tmp)
             err = snd_pcm_open(&(internal->pcm_handle), tmp="default",
                                SND_PCM_STREAM_PLAYBACK, 0);
-            if(err==0)break;
-            err = snd_pcm_open(&(internal->pcm_handle), tmp="hw:0",
-                               SND_PCM_STREAM_PLAYBACK, 0);
-          }
-          if(err==0)internal->dev=strdup(tmp);
+          internal->dev=strdup(tmp);
+
         }else
           err = snd_pcm_open(&(internal->pcm_handle), internal->dev,
                              SND_PCM_STREAM_PLAYBACK, 0);
@@ -424,7 +428,7 @@
           if(!strcasecmp(internal->dev,"default")){
             if(format->channels>2 && device->verbose>=0)
               fprintf(stderr,"\nWARNING: ALSA 'default' device plays only L,R channels.\n");
-            device->output_matrix=strdup("L,R,X,X,X,X,X,X,X,X,X");
+            device->output_matrix=strdup("L,R");
           }else
             device->output_matrix=strdup("L,R,BL,BR,C,LFE,SL,SR");
         }



More information about the commits mailing list