changeset 2059:3c390543302c

alsa9 pecs by joy_ping <joy@pingfm.org>
author pontscho
date Wed, 03 Oct 2001 18:09:51 +0000
parents b840d0913383
children 0048c2a8cc95
files libao2/ao_alsa1x.c libao2/ao_alsa9.c
diffstat 2 files changed, 56 insertions(+), 54 deletions(-) [+]
line wrap: on
line diff
--- a/libao2/ao_alsa1x.c	Wed Oct 03 17:40:56 2001 +0000
+++ b/libao2/ao_alsa1x.c	Wed Oct 03 18:09:51 2001 +0000
@@ -41,10 +41,10 @@
 static snd_pcm_hw_params_t *alsa_hwparams;
 static snd_pcm_sw_params_t *alsa_swparams;
 static char *alsa_device;
-#define ALSA_DEVICE_SIZE 48
+#define ALSA_DEVICE_SIZE 48 /* war 48 */
 
-static int alsa_fragsize = 8192; /* 4096 */
-static int alsa_fragcount = 8;
+static int alsa_fragsize = 8192; /* 4096 war 8192*/
+static int alsa_fragcount = 8; /* war 8 */
 
 /* to set/get/query special features/parameters */
 static int control(int cmd, int arg)
@@ -69,12 +69,12 @@
     return(CONTROL_UNKNOWN);
 }
 
-#undef start
-#define buffersize
-#undef buffertime
+#undef start /* war undef */
+#define buffersize 
+#undef buffertime /* war undef? */
 #define set_period
-#undef sw_params
-#undef set_start_mode
+#define sw_params /* war undef */
+#undef set_start_mode /* war undef */
 
 /*
     open & setup audio device
@@ -86,7 +86,7 @@
     int cards = -1;
     snd_pcm_info_t *alsa_info;
     
-    printf("alsa-init: Don't use this buggy driver, ALSA-0.9.x emulates OSS very well...\n");
+    printf("alsa-init: Don't use this buggy driver, ALSA-0.9.x emulates OSS very well... modified by me\n");
 
     printf("alsa-init: requested format: %d Hz, %d channels, %s\n", rate_hz,
 	channels, audio_out_format_name(format));
@@ -94,8 +94,7 @@
     alsa_handler = NULL;
 
     if (verbose)
-	printf("alsa-init: compiled for ALSA-%s (%d)\n", SND_LIB_VERSION_STR,
-	    SND_LIB_VERSION);
+	printf("alsa-init: compiled for ALSA-%s\n", SND_LIB_VERSION_STR);
 
     if ((err = snd_card_next(&cards)) < 0 || cards < 0)
     {
@@ -103,8 +102,9 @@
 	return(0);
     }
 
-    ao_samplerate = rate_hz;
+    ao_samplerate = rate_hz; /*war rate_hz */
     ao_bps = channels; /* really this is bytes per frame so bad varname */
+    /* ao_bps = channels */
     ao_format = format;
     ao_channels = channels;
     ao_outburst = OUTBURST;
@@ -217,13 +217,14 @@
 	return(0);
     }
 
-    if ((err = snd_pcm_hw_params_set_rate(alsa_handler, alsa_hwparams,
-	ao_samplerate, 0)) < 0)
-    {
-	printf("alsa-init: unable to set samplerate: %s\n",
-	    snd_strerror(err));
-	return(0);
-    }
+        if ((err = snd_pcm_hw_params_set_rate_near(alsa_handler, alsa_hwparams, ao_samplerate, 0)) < 0) 
+/* war nur snd_pcm_hw_params_set_rate */ 
+        {
+    	printf("alsa-init: unable to set samplerate-2: %s\n",
+    	    snd_strerror(err));
+	//snd_pcm_hw_params_dump(alsa_hwparams, errlog);
+    	return(0);
+        }
 
 #ifdef set_period
     {
@@ -257,10 +258,9 @@
 
 #ifdef buffertime
     {
-	int alsa_buffer_time = 60;
+      int alsa_buffer_time = 60; /* war 60 */
 
-	if ((err = snd_pcm_hw_params_set_buffer_time_near(alsa_handler, alsa_hwparams,
-	    alsa_buffer_time, 0)) < 0)
+	if ((err = snd_pcm_hw_params_set_buffer_time_near(alsa_handler, alsa_hwparams, alsa_buffer_time, 0)) < 0)
 	{
 	    printf("alsa-init: unable to set buffer time near: %s\n",
 		snd_strerror(err));
@@ -268,8 +268,8 @@
 	} else
 	    alsa_buffer_time = err;
 
-	if ((err = snd_pcm_hw_params_set_period_time_near(alsa_handler, alsa_hwparams,
-	    alsa_buffer_time/ao_bps, 0)) < 0)
+	if ((err = snd_pcm_hw_params_set_period_time_near(alsa_handler, alsa_hwparams, alsa_buffer_time/ao_bps, 0)) < 0)
+	  /* war alsa_buffer_time/ao_bps */
 	{
 	    printf("alsa-init: unable to set period time: %s\n",
 		snd_strerror(err));
@@ -451,8 +451,10 @@
 {
     int got_len;
 
-    if ((got_len = snd_pcm_writei(alsa_handler, data, (len/ao_bps))) != (len/ao_bps))
-    {
+    got_len = snd_pcm_writei(alsa_handler, data, len / 4);
+    
+      // war: if ((got_len = snd_pcm_writei(alsa_handler, data, (len/ao_bps))) != (len/ao_bps)) {     
+      
 	if (got_len == -EPIPE) /* underrun? */
 	{
 	    printf("alsa-play: alsa underrun, resetting stream\n");
@@ -468,7 +470,6 @@
 		return(0);
 	    }
 	    return(len); /* 2nd write was ok */
-	}
     }
     return(len);
 }
--- a/libao2/ao_alsa9.c	Wed Oct 03 17:40:56 2001 +0000
+++ b/libao2/ao_alsa9.c	Wed Oct 03 18:09:51 2001 +0000
@@ -41,10 +41,10 @@
 static snd_pcm_hw_params_t *alsa_hwparams;
 static snd_pcm_sw_params_t *alsa_swparams;
 static char *alsa_device;
-#define ALSA_DEVICE_SIZE 48
+#define ALSA_DEVICE_SIZE 48 /* war 48 */
 
-static int alsa_fragsize = 8192; /* 4096 */
-static int alsa_fragcount = 8;
+static int alsa_fragsize = 8192; /* 4096 war 8192*/
+static int alsa_fragcount = 8; /* war 8 */
 
 /* to set/get/query special features/parameters */
 static int control(int cmd, int arg)
@@ -69,12 +69,12 @@
     return(CONTROL_UNKNOWN);
 }
 
-#undef start
-#define buffersize
-#undef buffertime
+#undef start /* war undef */
+#define buffersize 
+#undef buffertime /* war undef? */
 #define set_period
-#undef sw_params
-#undef set_start_mode
+#define sw_params /* war undef */
+#undef set_start_mode /* war undef */
 
 /*
     open & setup audio device
@@ -86,7 +86,7 @@
     int cards = -1;
     snd_pcm_info_t *alsa_info;
     
-    printf("alsa-init: Don't use this buggy driver, ALSA-0.9.x emulates OSS very well...\n");
+    printf("alsa-init: Don't use this buggy driver, ALSA-0.9.x emulates OSS very well... modified by me\n");
 
     printf("alsa-init: requested format: %d Hz, %d channels, %s\n", rate_hz,
 	channels, audio_out_format_name(format));
@@ -94,8 +94,7 @@
     alsa_handler = NULL;
 
     if (verbose)
-	printf("alsa-init: compiled for ALSA-%s (%d)\n", SND_LIB_VERSION_STR,
-	    SND_LIB_VERSION);
+	printf("alsa-init: compiled for ALSA-%s\n", SND_LIB_VERSION_STR);
 
     if ((err = snd_card_next(&cards)) < 0 || cards < 0)
     {
@@ -103,8 +102,9 @@
 	return(0);
     }
 
-    ao_samplerate = rate_hz;
+    ao_samplerate = rate_hz; /*war rate_hz */
     ao_bps = channels; /* really this is bytes per frame so bad varname */
+    /* ao_bps = channels */
     ao_format = format;
     ao_channels = channels;
     ao_outburst = OUTBURST;
@@ -217,13 +217,14 @@
 	return(0);
     }
 
-    if ((err = snd_pcm_hw_params_set_rate(alsa_handler, alsa_hwparams,
-	ao_samplerate, 0)) < 0)
-    {
-	printf("alsa-init: unable to set samplerate: %s\n",
-	    snd_strerror(err));
-	return(0);
-    }
+        if ((err = snd_pcm_hw_params_set_rate_near(alsa_handler, alsa_hwparams, ao_samplerate, 0)) < 0) 
+/* war nur snd_pcm_hw_params_set_rate */ 
+        {
+    	printf("alsa-init: unable to set samplerate-2: %s\n",
+    	    snd_strerror(err));
+	//snd_pcm_hw_params_dump(alsa_hwparams, errlog);
+    	return(0);
+        }
 
 #ifdef set_period
     {
@@ -257,10 +258,9 @@
 
 #ifdef buffertime
     {
-	int alsa_buffer_time = 60;
+      int alsa_buffer_time = 60; /* war 60 */
 
-	if ((err = snd_pcm_hw_params_set_buffer_time_near(alsa_handler, alsa_hwparams,
-	    alsa_buffer_time, 0)) < 0)
+	if ((err = snd_pcm_hw_params_set_buffer_time_near(alsa_handler, alsa_hwparams, alsa_buffer_time, 0)) < 0)
 	{
 	    printf("alsa-init: unable to set buffer time near: %s\n",
 		snd_strerror(err));
@@ -268,8 +268,8 @@
 	} else
 	    alsa_buffer_time = err;
 
-	if ((err = snd_pcm_hw_params_set_period_time_near(alsa_handler, alsa_hwparams,
-	    alsa_buffer_time/ao_bps, 0)) < 0)
+	if ((err = snd_pcm_hw_params_set_period_time_near(alsa_handler, alsa_hwparams, alsa_buffer_time/ao_bps, 0)) < 0)
+	  /* war alsa_buffer_time/ao_bps */
 	{
 	    printf("alsa-init: unable to set period time: %s\n",
 		snd_strerror(err));
@@ -451,8 +451,10 @@
 {
     int got_len;
 
-    if ((got_len = snd_pcm_writei(alsa_handler, data, (len/ao_bps))) != (len/ao_bps))
-    {
+    got_len = snd_pcm_writei(alsa_handler, data, len / 4);
+    
+      // war: if ((got_len = snd_pcm_writei(alsa_handler, data, (len/ao_bps))) != (len/ao_bps)) {     
+      
 	if (got_len == -EPIPE) /* underrun? */
 	{
 	    printf("alsa-play: alsa underrun, resetting stream\n");
@@ -468,7 +470,6 @@
 		return(0);
 	    }
 	    return(len); /* 2nd write was ok */
-	}
     }
     return(len);
 }