changeset 7050:a5b2b377ab50

changed spdif default from "hw:0,2" to general alias "iec958" based on a patch by Benedikt Hunz <hunz@hunz.org> corrected typo in ugly spdif-warning message added 32/20bit modes for 'high-end'-soundcards disabled hw-mixer-access for big-endian machines (mplayer seems to screw up hw-mixer on LinuxPPC running ALSA needs more testing, but its safer to disable it for now.)
author joyping
date Tue, 20 Aug 2002 14:15:25 +0000
parents 0caeda287ff9
children d03fad6123a3
files libao2/ao_alsa1x.c libao2/ao_alsa9.c
diffstat 2 files changed, 126 insertions(+), 96 deletions(-) [+]
line wrap: on
line diff
--- a/libao2/ao_alsa1x.c	Tue Aug 20 00:57:13 2002 +0000
+++ b/libao2/ao_alsa1x.c	Tue Aug 20 14:15:25 2002 +0000
@@ -140,17 +140,9 @@
        }
        if ((err = snd_ctl_elem_write(ctl_handler, ctl)) < 0) {
 	 //fprintf(stderr, "Unable to update the IEC958 control: %s\n", snd_strerror(err));
-	 printf("alsa-spdif-init: cant set spdif-trough automatically\n");
+	 printf("alsa-spdif-init: cant set spdif-through automatically\n");
         goto __diga_end;
        }
-       	//test area
-       /* elem_device = snd_ctl_elem_id_get_device(elem_id); */
-       /* elem_name = snd_ctl_elem_value_get_name(ctl);  */
-       /* snd_ctl_elem_value_get_iec958(ctl, &spdif); */
-       /* printf("spdif = %i, device = %i\n", &spdif, elem_device); */
-       /* printf("name = %s\n", elem_name); */
-	//end test area
-
 
       snd_ctl_close(ctl_handler);
       __diga_end:                                                       
@@ -211,6 +203,8 @@
     return CONTROL_TRUE;
   case AOCONTROL_GET_VOLUME:
   case AOCONTROL_SET_VOLUME:
+#ifndef WORDS_BIGENDIAN 
+{ //seems to be a problem on macs?
     {
       ao_control_vol_t *vol = (ao_control_vol_t *)arg;
 
@@ -303,7 +297,17 @@
       snd_mixer_close(handle);
       return CONTROL_OK;
     }
+}// end big-endian
+#endif
+#ifdef WORDS_BIGENDIAN
+{
+  {
+    return (CONTROL_UNKNOWN);
   }
+}
+#endif
+    
+  } //end witch
   return(CONTROL_UNKNOWN);
 }
 
@@ -344,49 +348,60 @@
     //ao_data.buffersize = MAX_OUTBURST; // was 16384
 
     switch (format)
-    {
-	case AFMT_S8:
-	    alsa_format = SND_PCM_FORMAT_S8;
-	    break;
-	case AFMT_U8:
-	    alsa_format = SND_PCM_FORMAT_U8;
-	    break;
-	case AFMT_U16_LE:
-	    alsa_format = SND_PCM_FORMAT_U16_LE;
-	    break;
-	case AFMT_U16_BE:
-	    alsa_format = SND_PCM_FORMAT_U16_BE;
-	    break;
+      {
+      case AFMT_S8:
+	alsa_format = SND_PCM_FORMAT_S8;
+	break;
+      case AFMT_U8:
+	alsa_format = SND_PCM_FORMAT_U8;
+	break;
+      case AFMT_U16_LE:
+	alsa_format = SND_PCM_FORMAT_U16_LE;
+	break;
+      case AFMT_U16_BE:
+	alsa_format = SND_PCM_FORMAT_U16_BE;
+	break;
 #ifndef WORDS_BIGENDIAN
-	case AFMT_AC3:
+      case AFMT_AC3:
 #endif
-	case AFMT_S16_LE:
-	    alsa_format = SND_PCM_FORMAT_S16_LE;
-	    break;
+      case AFMT_S16_LE:
+	alsa_format = SND_PCM_FORMAT_S16_LE;
+	break;
 #ifdef WORDS_BIGENDIAN
-	case AFMT_AC3:
+      case AFMT_AC3:
 #endif
-	case AFMT_S16_BE:
-	    alsa_format = SND_PCM_FORMAT_S16_BE;
-	    break;
-	default:
-	    alsa_format = SND_PCM_FORMAT_MPEG;
-	    break;
-    }
+      case AFMT_S16_BE:
+	alsa_format = SND_PCM_FORMAT_S16_BE;
+	break;
+      case AFMT_S32_LE:
+	alsa_format = SND_PCM_FORMAT_S32_LE;
+	break;
+      case AFMT_S32_BE:
+	alsa_format = SND_PCM_FORMAT_S32_BE;
+	break;
+
+      default:
+	alsa_format = SND_PCM_FORMAT_MPEG;
+	break;
+      }
     
     switch(alsa_format)
-    {
-	case SND_PCM_FORMAT_S16_LE:
-	case SND_PCM_FORMAT_U16_LE:
-	    ao_data.bps *= 2;
-	    break;
-	case -1:
-	    printf("alsa-init: invalid format (%s) requested - output disabled\n",
-		audio_out_format_name(format));
-	    return(0);
-	default:
-	    break;	    
-    }
+      {
+      case SND_PCM_FORMAT_S16_LE:
+      case SND_PCM_FORMAT_U16_LE:
+	ao_data.bps *= 2;
+	break;
+      case SND_PCM_FORMAT_S32_LE:
+      case SND_PCM_FORMAT_S32_BE:
+	ao_data.bps *= 4;
+	break;
+      case -1:
+	printf("alsa-init: invalid format (%s) requested - output disabled\n",
+	       audio_out_format_name(format));
+	return(0);
+      default:
+	break;	    
+      }
     
     if (ao_subdevice) {
       //start parsing ao_subdevice, ugly and not thread safe!
@@ -498,7 +513,7 @@
       if (device_set)
 	alsa_handler = spdif_init(alsa_device);
       else
-	alsa_handler = spdif_init("hw:0,2");
+	alsa_handler = spdif_init("iec958");
     }
 
     //setting modes for block or nonblock-mode
@@ -512,7 +527,7 @@
       set_block_mode = 0;
       str_block_mode = "block-mode";
     }
-    //cvs cosmetics fix
+
     //sets buff/chunksize if its set manually
     if (ao_data.buffersize) {
       switch (ao_data.buffersize)
--- a/libao2/ao_alsa9.c	Tue Aug 20 00:57:13 2002 +0000
+++ b/libao2/ao_alsa9.c	Tue Aug 20 14:15:25 2002 +0000
@@ -140,17 +140,9 @@
        }
        if ((err = snd_ctl_elem_write(ctl_handler, ctl)) < 0) {
 	 //fprintf(stderr, "Unable to update the IEC958 control: %s\n", snd_strerror(err));
-	 printf("alsa-spdif-init: cant set spdif-trough automatically\n");
+	 printf("alsa-spdif-init: cant set spdif-through automatically\n");
         goto __diga_end;
        }
-       	//test area
-       /* elem_device = snd_ctl_elem_id_get_device(elem_id); */
-       /* elem_name = snd_ctl_elem_value_get_name(ctl);  */
-       /* snd_ctl_elem_value_get_iec958(ctl, &spdif); */
-       /* printf("spdif = %i, device = %i\n", &spdif, elem_device); */
-       /* printf("name = %s\n", elem_name); */
-	//end test area
-
 
       snd_ctl_close(ctl_handler);
       __diga_end:                                                       
@@ -211,6 +203,8 @@
     return CONTROL_TRUE;
   case AOCONTROL_GET_VOLUME:
   case AOCONTROL_SET_VOLUME:
+#ifndef WORDS_BIGENDIAN 
+{ //seems to be a problem on macs?
     {
       ao_control_vol_t *vol = (ao_control_vol_t *)arg;
 
@@ -303,7 +297,17 @@
       snd_mixer_close(handle);
       return CONTROL_OK;
     }
+}// end big-endian
+#endif
+#ifdef WORDS_BIGENDIAN
+{
+  {
+    return (CONTROL_UNKNOWN);
   }
+}
+#endif
+    
+  } //end witch
   return(CONTROL_UNKNOWN);
 }
 
@@ -344,49 +348,60 @@
     //ao_data.buffersize = MAX_OUTBURST; // was 16384
 
     switch (format)
-    {
-	case AFMT_S8:
-	    alsa_format = SND_PCM_FORMAT_S8;
-	    break;
-	case AFMT_U8:
-	    alsa_format = SND_PCM_FORMAT_U8;
-	    break;
-	case AFMT_U16_LE:
-	    alsa_format = SND_PCM_FORMAT_U16_LE;
-	    break;
-	case AFMT_U16_BE:
-	    alsa_format = SND_PCM_FORMAT_U16_BE;
-	    break;
+      {
+      case AFMT_S8:
+	alsa_format = SND_PCM_FORMAT_S8;
+	break;
+      case AFMT_U8:
+	alsa_format = SND_PCM_FORMAT_U8;
+	break;
+      case AFMT_U16_LE:
+	alsa_format = SND_PCM_FORMAT_U16_LE;
+	break;
+      case AFMT_U16_BE:
+	alsa_format = SND_PCM_FORMAT_U16_BE;
+	break;
 #ifndef WORDS_BIGENDIAN
-	case AFMT_AC3:
+      case AFMT_AC3:
 #endif
-	case AFMT_S16_LE:
-	    alsa_format = SND_PCM_FORMAT_S16_LE;
-	    break;
+      case AFMT_S16_LE:
+	alsa_format = SND_PCM_FORMAT_S16_LE;
+	break;
 #ifdef WORDS_BIGENDIAN
-	case AFMT_AC3:
+      case AFMT_AC3:
 #endif
-	case AFMT_S16_BE:
-	    alsa_format = SND_PCM_FORMAT_S16_BE;
-	    break;
-	default:
-	    alsa_format = SND_PCM_FORMAT_MPEG;
-	    break;
-    }
+      case AFMT_S16_BE:
+	alsa_format = SND_PCM_FORMAT_S16_BE;
+	break;
+      case AFMT_S32_LE:
+	alsa_format = SND_PCM_FORMAT_S32_LE;
+	break;
+      case AFMT_S32_BE:
+	alsa_format = SND_PCM_FORMAT_S32_BE;
+	break;
+
+      default:
+	alsa_format = SND_PCM_FORMAT_MPEG;
+	break;
+      }
     
     switch(alsa_format)
-    {
-	case SND_PCM_FORMAT_S16_LE:
-	case SND_PCM_FORMAT_U16_LE:
-	    ao_data.bps *= 2;
-	    break;
-	case -1:
-	    printf("alsa-init: invalid format (%s) requested - output disabled\n",
-		audio_out_format_name(format));
-	    return(0);
-	default:
-	    break;	    
-    }
+      {
+      case SND_PCM_FORMAT_S16_LE:
+      case SND_PCM_FORMAT_U16_LE:
+	ao_data.bps *= 2;
+	break;
+      case SND_PCM_FORMAT_S32_LE:
+      case SND_PCM_FORMAT_S32_BE:
+	ao_data.bps *= 4;
+	break;
+      case -1:
+	printf("alsa-init: invalid format (%s) requested - output disabled\n",
+	       audio_out_format_name(format));
+	return(0);
+      default:
+	break;	    
+      }
     
     if (ao_subdevice) {
       //start parsing ao_subdevice, ugly and not thread safe!
@@ -498,7 +513,7 @@
       if (device_set)
 	alsa_handler = spdif_init(alsa_device);
       else
-	alsa_handler = spdif_init("hw:0,2");
+	alsa_handler = spdif_init("iec958");
     }
 
     //setting modes for block or nonblock-mode
@@ -512,7 +527,7 @@
       set_block_mode = 0;
       str_block_mode = "block-mode";
     }
-    //cvs cosmetics fix
+
     //sets buff/chunksize if its set manually
     if (ao_data.buffersize) {
       switch (ao_data.buffersize)