[Mplayer-cvslog] CVS: main/libao2 ao_alsa1x.c, 1.41, 1.42 audio_out.c, 1.34, 1.35

Jindrich Makovicka CVS henry at mplayerhq.hu
Sun Jan 11 18:07:34 CET 2004


Update of /cvsroot/mplayer/main/libao2
In directory mail:/scsi/2/tmp/cvs-serv18040/libao2

Modified Files:
	ao_alsa1x.c audio_out.c 
Log Message:
ALSA 1.x audio out driver

Index: ao_alsa1x.c
===================================================================
RCS file: /cvsroot/mplayer/main/libao2/ao_alsa1x.c,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -r1.41 -r1.42
--- ao_alsa1x.c	10 Jan 2004 09:10:52 -0000	1.41
+++ ao_alsa1x.c	11 Jan 2004 17:07:32 -0000	1.42
@@ -1,5 +1,5 @@
 /*
-  ao_alsa9 - ALSA-0.9.x output plugin for MPlayer
+  ao_alsa1x - ALSA-1.x output plugin for MPlayer
 
   (C) Alex Beregszaszi
   
@@ -7,6 +7,8 @@
   additional AC3 passthrough support by Andy Lo A Foe <andy at alsaplayer.org>  
   08/22/2002 iec958-init rewritten and merged with common init, joy
   
+  Trivial port to ALSA 1.x API by Jindrich Makovicka
+  
   Any bugreports regarding to this driver are welcome.
 */
 
@@ -36,13 +38,13 @@
 
 static ao_info_t info = 
 {
-    "ALSA-0.9.x audio output",
-    "alsa9",
+    "ALSA-1.x audio output",
+    "alsa1x",
     "Alex Beregszaszi, Joy Winter <joy at pingfm.org>",
     "under developement"
 };
 
-LIBAO_EXTERN(alsa9)
+LIBAO_EXTERN(alsa1x)
 
 
 static snd_pcm_t *alsa_handler;
@@ -58,7 +60,7 @@
  * which seems to be good avarge for most situations 
  * so buffersize is 16384 frames by default */
 static int alsa_fragcount = 16;
-static int chunk_size = 1024; //is alsa_fragsize / 4
+static snd_pcm_uframes_t chunk_size = 1024; //is alsa_fragsize / 4
 
 #define MIN_CHUNK_SIZE 1024
 
@@ -77,6 +79,8 @@
 
 #undef BUFFERTIME
 #define SET_CHUNKSIZE
+//#define BUFFERTIME
+//#undef SET_CHUNKSIZE
 #undef USE_POLL
 
 
@@ -97,7 +101,7 @@
       snd_mixer_elem_t *elem;
       snd_mixer_selem_id_t *sid;
 
-      static const char *mix_name = NULL;
+      static char *mix_name = NULL;
       static char *card = NULL;
 
       long pmin, pmax;
@@ -211,7 +215,8 @@
 {
     int err;
     int cards = -1;
-    int period_val;
+    int dir;
+    snd_pcm_uframes_t bufsize;
     snd_pcm_info_t *alsa_info;
     char *str_block_mode;
     int device_set = 0;
@@ -358,6 +363,7 @@
             alsa_device = devstr;
            break;
           default:
+	   break;
         }
     }
 
@@ -450,7 +456,7 @@
 	printf("           mmap: sets mmap-mode\n");
 	printf("           noblock: sets noblock-mode\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("           example -ao alsa1x: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 {
@@ -538,7 +544,7 @@
 	printf("alsa-init: error set block-mode %s\n", snd_strerror(err));
       }
       else if (verbose>0) {
-	printf("alsa-init: pcm opend in %s\n", str_block_mode);
+	printf("alsa-init: pcm opened in %s\n", str_block_mode);
       }
       
       snd_pcm_hw_params_alloca(&alsa_hwparams);
@@ -599,7 +605,8 @@
 	  return(0);
 	}
 
-      if ((err = snd_pcm_hw_params_set_rate_near(alsa_handler, alsa_hwparams, ao_data.samplerate, 0)) < 0) 
+      dir = 0;
+      if ((err = snd_pcm_hw_params_set_rate_near(alsa_handler, alsa_hwparams, &ao_data.samplerate, &dir)) < 0) 
         {
 	  printf("alsa-init: unable to set samplerate-2: %s\n",
 		 snd_strerror(err));
@@ -609,16 +616,20 @@
 #ifdef BUFFERTIME
       {
 	int alsa_buffer_time = 500000; /* original 60 */
+	int alsa_period_time;
 
-	if ((err = snd_pcm_hw_params_set_buffer_time_near(alsa_handler, alsa_hwparams, alsa_buffer_time, 0)) < 0)
+	dir = 0;
+	if ((err = snd_pcm_hw_params_set_buffer_time_near(alsa_handler, alsa_hwparams, &alsa_buffer_time, &dir)) < 0)
 	  {
 	    printf("alsa-init: unable to set buffer time near: %s\n",
 		   snd_strerror(err));
 	    return(0);
-	  } else
-	    alsa_buffer_time = err;
+	  }
 
-	if ((err = snd_pcm_hw_params_set_period_time_near(alsa_handler, alsa_hwparams, alsa_buffer_time/4, 0)) < 0)
+	alsa_period_time = alsa_buffer_time/4; ;
+
+	dir = 0;
+	if ((err = snd_pcm_hw_params_set_period_time_near(alsa_handler, alsa_hwparams, alsa_period_time, &dir)) < 0)
 	  /* original: alsa_buffer_time/ao_data.bps */
 	  {
 	    printf("alsa-init: unable to set period time: %s\n",
@@ -626,14 +637,15 @@
 	    return(0);
 	  }
 	if (verbose>0)
-	  printf("alsa-init: buffer_time: %d, period_time :%d\n",alsa_buffer_time, err);
+	  printf("alsa-init: buffer_time: %d, period_time :%d\n",alsa_buffer_time, alsa_period_time);
       }
 #endif
 
 #ifdef SET_CHUNKSIZE
       {
 	//set chunksize
-	if ((err = snd_pcm_hw_params_set_period_size(alsa_handler, alsa_hwparams, chunk_size, 0)) < 0)
+	dir = 0;
+	if ((err = snd_pcm_hw_params_set_period_size_near(alsa_handler, alsa_hwparams, &chunk_size, &dir)) < 0)
 	  {
 	    printf("alsa-init: unable to set periodsize: %s\n", snd_strerror(err));
 	    return(0);
@@ -642,17 +654,13 @@
 	  printf("alsa-init: chunksize set to %i\n", chunk_size);
 	}
 
-	//set period_count
-	if ((period_val = snd_pcm_hw_params_get_periods_max(alsa_hwparams, 0)) < alsa_fragcount) {
-	  alsa_fragcount = period_val;			
+	dir = 0;
+	if ((err = snd_pcm_hw_params_set_periods_near(alsa_handler, alsa_hwparams, &alsa_fragcount, &dir)) < 0) {
+	  printf("alsa-init: unable to set periods: %s\n", snd_strerror(err));
 	}
 
 	if (verbose>0)
-	  printf("alsa-init: current val=%i, fragcount=%i\n", period_val, alsa_fragcount);
-
-	if ((err = snd_pcm_hw_params_set_periods(alsa_handler, alsa_hwparams, alsa_fragcount, 0)) < 0) {
-	  printf("alsa-init: unable to set periods: %s\n", snd_strerror(err));
-	}
+	  printf("alsa-init: fragcount=%i\n", alsa_fragcount);
       }
 #endif
 
@@ -667,13 +675,13 @@
 
 
       // gets buffersize for control
-      if ((err = snd_pcm_hw_params_get_buffer_size(alsa_hwparams)) < 0)
+      if ((err = snd_pcm_hw_params_get_buffer_size(alsa_hwparams, &bufsize)) < 0)
 	{
 	  printf("alsa-init: unable to get buffersize: %s\n", snd_strerror(err));
 	  return(0);
 	}
       else {
-	ao_data.buffersize = err * bytes_per_sample;
+	ao_data.buffersize = bufsize * bytes_per_sample;
 	if (verbose>0)
 	  printf("alsa-init: got buffersize=%i\n", ao_data.buffersize);
       }
@@ -717,7 +725,7 @@
 	  return(0);
 	}
 
-      printf("alsa9: %d Hz/%d channels/%d bpf/%d bytes buffer/%s\n",
+      printf("alsa1x: %d Hz/%d channels/%d bpf/%d bytes buffer/%s\n",
 	     ao_data.samplerate, ao_data.channels, bytes_per_sample, ao_data.buffersize,
 	     snd_pcm_format_description(alsa_format));
 

Index: audio_out.c
===================================================================
RCS file: /cvsroot/mplayer/main/libao2/audio_out.c,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -r1.34 -r1.35
--- audio_out.c	21 May 2003 21:10:55 -0000	1.34
+++ audio_out.c	11 Jan 2004 17:07:32 -0000	1.35
@@ -29,6 +29,9 @@
 #ifdef HAVE_ALSA9
  extern ao_functions_t audio_out_alsa9;
 #endif
+#ifdef HAVE_ALSA1X
+ extern ao_functions_t audio_out_alsa1x;
+#endif
 #ifdef HAVE_NAS
 extern ao_functions_t audio_out_nas;
 #endif
@@ -72,6 +75,9 @@
 #ifdef USE_OSS_AUDIO
         &audio_out_oss,
 #endif
+#ifdef HAVE_ALSA1X
+	&audio_out_alsa1x,
+#endif
 #ifdef HAVE_ALSA9
 	&audio_out_alsa9,
 #endif




More information about the MPlayer-cvslog mailing list