[alsa-devel] S16_LE + softvol = bad

Takashi Iwai tiwai at suse.de
Thu Jan 17 15:23:33 CET 2008


At Thu, 17 Jan 2008 15:11:18 +0100,
I wrote:
> 
> At Thu, 17 Jan 2008 15:00:47 +0100,
> Clemens Ladisch wrote:
> > 
> > Alexander E. Patrakov wrote:
> > > some cards (most notably, Intel HD audio) have the PCM control as softvol, and 
> > > default to S16_LE as a format for dmix.
> > 
> > HDA-Intel.conf doesn't set a sample format, and when none is set, dmix
> > tries S32 before S16.  You get S16 only if the device doesn't support
> > S32.
> 
> The plugin code is written partly in such a way, but the other parts
> do require the format given explicitly.  So, it doesn't work as is.
> Fixing this wouldn't be hard, I guess, though.

... and the below is the fix.  Give it a try.


Takashi

diff -r f20b309ff22a src/conf/alsa.conf
--- a/src/conf/alsa.conf	Tue Jan 15 14:29:34 2008 +0100
+++ b/src/conf/alsa.conf	Thu Jan 17 15:18:53 2008 +0100
@@ -68,7 +68,7 @@ defaults.pcm.ipc_perm 0660
 defaults.pcm.ipc_perm 0660
 defaults.pcm.dmix.max_periods 0
 defaults.pcm.dmix.rate 48000
-defaults.pcm.dmix.format S16_LE
+defaults.pcm.dmix.format "unchanged"
 defaults.pcm.dmix.card defaults.pcm.card
 defaults.pcm.dmix.device defaults.pcm.device
 defaults.pcm.dsnoop.card defaults.pcm.card
diff -r f20b309ff22a src/pcm/pcm_direct.c
--- a/src/pcm/pcm_direct.c	Tue Jan 15 14:29:34 2008 +0100
+++ b/src/pcm/pcm_direct.c	Thu Jan 17 15:18:53 2008 +0100
@@ -874,7 +874,11 @@ int snd_pcm_direct_initialize_slave(snd_
 			return ret;
 		}
 	}
-	ret = snd_pcm_hw_params_set_format(spcm, hw_params, params->format);
+	if (params->format == SND_PCM_FORMAT_UNKNOWN)
+		ret = -EINVAL;
+	else
+		ret = snd_pcm_hw_params_set_format(spcm, hw_params,
+						   params->format);
 	if (ret < 0) {
 		static const snd_pcm_format_t dmix_formats[] = {
 			SND_PCM_FORMAT_S32,
diff -r f20b309ff22a src/pcm/pcm_dmix.c
--- a/src/pcm/pcm_dmix.c	Tue Jan 15 14:29:34 2008 +0100
+++ b/src/pcm/pcm_dmix.c	Thu Jan 17 15:18:53 2008 +0100
@@ -1267,7 +1267,7 @@ int _snd_pcm_dmix_open(snd_pcm_t **pcmp,
 	params.periods = 3;
 
 	err = snd_pcm_slave_conf(root, dopen.slave, &sconf, 8,
-				 SND_PCM_HW_PARAM_FORMAT, 0, &params.format,
+				 SND_PCM_HW_PARAM_FORMAT, SCONF_UNCHANGED, &params.format,
 				 SND_PCM_HW_PARAM_RATE, 0, &params.rate,
 				 SND_PCM_HW_PARAM_CHANNELS, 0, &params.channels,
 				 SND_PCM_HW_PARAM_PERIOD_TIME, 0, &params.period_time,
@@ -1282,8 +1282,10 @@ int _snd_pcm_dmix_open(snd_pcm_t **pcmp,
 	if (psize == -1 && params.period_time == -1)
 		params.period_time = 125000;    /* 0.125 seconds */
 
-	/* sorry, limited features */
-	if (! (dmix_supported_format & (1ULL << params.format))) {
+	if (params.format == -2)
+		params.format = SND_PCM_FORMAT_UNKNOWN;
+	else if (!(dmix_supported_format & (1ULL << params.format))) {
+		/* sorry, limited features */
 		SNDERR("Unsupported format");
 		snd_config_delete(sconf);
 		return -EINVAL;


More information about the Alsa-devel mailing list