changeset 1146:a84610bb5476

hacked aocontrol_set_device working, and cleaned up a bit
author al3x
date Sun, 17 Jun 2001 17:44:56 +0000
parents 065583b867fd
children 82bbd3ee8ce7
files libao2/ao_alsa1x.c libao2/ao_alsa9.c
diffstat 2 files changed, 48 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/libao2/ao_alsa1x.c	Sun Jun 17 17:43:04 2001 +0000
+++ b/libao2/ao_alsa1x.c	Sun Jun 17 17:44:56 2001 +0000
@@ -50,10 +50,19 @@
     switch(cmd)
     {
 	case AOCONTROL_GET_DEVICE:
-	    return(char *)alsa_device; /* egy kicsit brutalis, dehat :) */
+	    return((char *)alsa_device); /* egy kicsit brutalis, dehat :) */
 	case AOCONTROL_SET_DEVICE:
+	{
+	    int ret;
+
 	    strncpy(alsa_device, (char *)arg, ALSA_DEVICE_SIZE);
-	    break;
+	    uninit();
+	    ret = init(ao_samplerate, ao_channels, ao_format, 0);
+	    if (ret == 0)
+		return(CONTROL_ERROR);
+	    else
+		return(CONTROL_OK);
+	}
     }
     return(CONTROL_UNKNOWN);
 }
@@ -142,17 +151,20 @@
 	return(0);
     }
 
-    if ((alsa_device = malloc(ALSA_DEVICE_SIZE)) == NULL)
+    if (alsa_device == NULL)
     {
-	printf("alsa-init: memory allocation error: %s\n", strerror(errno));
-	return(0);
-    }
+	if ((alsa_device = malloc(ALSA_DEVICE_SIZE)) == NULL)
+	{
+	    printf("alsa-init: memory allocation error: %s\n", strerror(errno));
+	    return(0);
+	}
 
-    snprintf(alsa_device, ALSA_DEVICE_SIZE, "hw:%d,%d",
-	snd_pcm_info_get_device(alsa_info),
-	snd_pcm_info_get_subdevice(alsa_info));
+	snprintf(alsa_device, ALSA_DEVICE_SIZE, "hw:%d,%d",
+	    snd_pcm_info_get_device(alsa_info),
+	    snd_pcm_info_get_subdevice(alsa_info));
 
-    snd_pcm_info_free(alsa_info);
+	snd_pcm_info_free(alsa_info);
+    }
 
     printf("alsa-init: %d soundcard%s found, using: %s\n", cards+1,
 	(cards >= 0) ? "" : "s", alsa_device);
@@ -230,8 +242,9 @@
 	return(0);
     } else
     {
-        printf("alsa-init: got buffersize %i\n", err);
 	ao_buffersize = err;
+        if (verbose)
+	    printf("alsa-init: got buffersize %i\n", ao_buffersize);
     }
 #endif
 
--- a/libao2/ao_alsa9.c	Sun Jun 17 17:43:04 2001 +0000
+++ b/libao2/ao_alsa9.c	Sun Jun 17 17:44:56 2001 +0000
@@ -50,10 +50,19 @@
     switch(cmd)
     {
 	case AOCONTROL_GET_DEVICE:
-	    return(char *)alsa_device; /* egy kicsit brutalis, dehat :) */
+	    return((char *)alsa_device); /* egy kicsit brutalis, dehat :) */
 	case AOCONTROL_SET_DEVICE:
+	{
+	    int ret;
+
 	    strncpy(alsa_device, (char *)arg, ALSA_DEVICE_SIZE);
-	    break;
+	    uninit();
+	    ret = init(ao_samplerate, ao_channels, ao_format, 0);
+	    if (ret == 0)
+		return(CONTROL_ERROR);
+	    else
+		return(CONTROL_OK);
+	}
     }
     return(CONTROL_UNKNOWN);
 }
@@ -142,17 +151,20 @@
 	return(0);
     }
 
-    if ((alsa_device = malloc(ALSA_DEVICE_SIZE)) == NULL)
+    if (alsa_device == NULL)
     {
-	printf("alsa-init: memory allocation error: %s\n", strerror(errno));
-	return(0);
-    }
+	if ((alsa_device = malloc(ALSA_DEVICE_SIZE)) == NULL)
+	{
+	    printf("alsa-init: memory allocation error: %s\n", strerror(errno));
+	    return(0);
+	}
 
-    snprintf(alsa_device, ALSA_DEVICE_SIZE, "hw:%d,%d",
-	snd_pcm_info_get_device(alsa_info),
-	snd_pcm_info_get_subdevice(alsa_info));
+	snprintf(alsa_device, ALSA_DEVICE_SIZE, "hw:%d,%d",
+	    snd_pcm_info_get_device(alsa_info),
+	    snd_pcm_info_get_subdevice(alsa_info));
 
-    snd_pcm_info_free(alsa_info);
+	snd_pcm_info_free(alsa_info);
+    }
 
     printf("alsa-init: %d soundcard%s found, using: %s\n", cards+1,
 	(cards >= 0) ? "" : "s", alsa_device);
@@ -230,8 +242,9 @@
 	return(0);
     } else
     {
-        printf("alsa-init: got buffersize %i\n", err);
 	ao_buffersize = err;
+        if (verbose)
+	    printf("alsa-init: got buffersize %i\n", ao_buffersize);
     }
 #endif