[MPlayer-cvslog] CVS: main/libao2 ao_alsa.c,1.19,1.20

Jindrich Makovicka CVS syncmail at mplayerhq.hu
Thu Aug 25 23:46:34 CEST 2005


CVS change done by Jindrich Makovicka CVS

Update of /cvsroot/mplayer/main/libao2
In directory mail:/var2/tmp/cvs-serv25582

Modified Files:
	ao_alsa.c 
Log Message:
reordered bps calculation

Index: ao_alsa.c
===================================================================
RCS file: /cvsroot/mplayer/main/libao2/ao_alsa.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- ao_alsa.c	25 Aug 2005 19:57:32 -0000	1.19
+++ ao_alsa.c	25 Aug 2005 21:46:32 -0000	1.20
@@ -284,7 +284,6 @@
     }
 
     ao_data.samplerate = rate_hz;
-    ao_data.bps = channels * rate_hz;
     ao_data.format = format;
     ao_data.channels = channels;
     ao_data.outburst = OUTBURST;
@@ -330,34 +329,6 @@
 	break;
       }
     
-    //setting bw according to the input-format. resolution seems to be always s16_le or
-    //u16_le so 32bit is probably obsolet. 
-    switch(alsa_format)
-      {
-      case SND_PCM_FORMAT_S8:
-      case SND_PCM_FORMAT_U8:
-	ao_data.bps *= 1;
-	break;
-      case SND_PCM_FORMAT_S16_LE:
-      case SND_PCM_FORMAT_U16_LE:
-      case SND_PCM_FORMAT_S16_BE:
-      case SND_PCM_FORMAT_U16_BE:
-	ao_data.bps *= 2;
-	break;
-      case SND_PCM_FORMAT_S32_LE:
-      case SND_PCM_FORMAT_S32_BE:
-      case SND_PCM_FORMAT_FLOAT_LE:
-	ao_data.bps *= 4;
-	break;
-      case -1:
-	mp_msg(MSGT_AO,MSGL_ERR,"alsa-init: invalid format (%s) requested - output disabled\n",af_fmt2str_short(format));
-	return(0);
-	break;
-      default:
-	ao_data.bps *= 2;
-	mp_msg(MSGT_AO,MSGL_WARN,"alsa-init: couldn't convert to right format. setting bps to: %d", ao_data.bps);
-      }
-
     //subdevice parsing
     // set defaults
     ao_mmap = 0;
@@ -537,12 +508,8 @@
 		"alsa-init: format %s are not supported by hardware, trying default\n", af_fmt2str_short(format));
          alsa_format = SND_PCM_FORMAT_S16_LE;
          ao_data.format = AF_FORMAT_S16_LE;
-         ao_data.bps = channels * rate_hz * 2;
       }
 
-      bytes_per_sample = ao_data.bps / ao_data.samplerate; //it should be here
-
-    
       if ((err = snd_pcm_hw_params_set_format(alsa_handler, alsa_hwparams,
 					      alsa_format)) < 0)
 	{
@@ -567,6 +534,38 @@
 	  return(0);
         }
 
+    ao_data.bps = ao_data.channels * ao_data.samplerate;
+
+    //setting bw according to the input-format. resolution seems to be always s16_le or
+    //u16_le so 32bit is probably obsolet. 
+    switch(alsa_format)
+      {
+      case SND_PCM_FORMAT_S8:
+      case SND_PCM_FORMAT_U8:
+	ao_data.bps *= 1;
+	break;
+      case SND_PCM_FORMAT_S16_LE:
+      case SND_PCM_FORMAT_U16_LE:
+      case SND_PCM_FORMAT_S16_BE:
+      case SND_PCM_FORMAT_U16_BE:
+	ao_data.bps *= 2;
+	break;
+      case SND_PCM_FORMAT_S32_LE:
+      case SND_PCM_FORMAT_S32_BE:
+      case SND_PCM_FORMAT_FLOAT_LE:
+	ao_data.bps *= 4;
+	break;
+      case -1:
+	mp_msg(MSGT_AO,MSGL_ERR,"alsa-init: invalid format (%s) requested - output disabled\n",af_fmt2str_short(format));
+	return(0);
+	break;
+      default:
+	ao_data.bps *= 2;
+	mp_msg(MSGT_AO,MSGL_WARN,"alsa-init: couldn't convert to right format. setting bps to: %d", ao_data.bps);
+      }
+
+    bytes_per_sample = ao_data.bps / ao_data.samplerate;
+
 #ifdef BUFFERTIME
       {
 	int alsa_buffer_time = 500000; /* original 60 */
@@ -661,7 +660,7 @@
 	    }
 
 	  bits_per_sample = snd_pcm_format_physical_width(alsa_format);
-	  bits_per_frame = bits_per_sample * channels;
+	  bits_per_frame = bits_per_sample * ao_data.channels;
 	  chunk_bytes = chunk_size * bits_per_frame / 8;
 
 	    mp_msg(MSGT_AO,MSGL_V,"alsa-init: bits per sample (bps)=%i, bits per frame (bpf)=%i, chunk_bytes=%i\n",bits_per_sample,bits_per_frame,chunk_bytes);}




More information about the MPlayer-cvslog mailing list