[alsa-devel] [PATCH] hda-emu: Add support for channel mapping API

Takashi Iwai tiwai at suse.de
Mon Sep 17 12:18:28 CEST 2012


At Mon, 17 Sep 2012 11:56:37 +0200,
David Henningsson wrote:
> 
> Hi Takashi,
> 
> I tried to make hda-emu compile with the latest changes to the HDA driver.
> This is the result. It compiles, but when running any codec, I get the error
> "Control element Playback Channel Map:0 already exists!".
> I'm unsure whether this is a problem in the driver or in my simple copy-paste
> attempt to make this work.
> Can you offer some insight?

It's an issue in hda-emu.  For simplicity, hda-emu didn't touch the
ALSA PCM instance at all, so pcm->number is always zero.

An additional patch below should fix the problem.


Takashi

---
diff --git a/hda-emu.c b/hda-emu.c
index 2a2b3d1..6712849 100644
--- a/hda-emu.c
+++ b/hda-emu.c
@@ -717,8 +717,6 @@ void hda_test_pcm(int id, int op, int subid,
 static int attach_pcm(struct hda_bus *bus, struct hda_codec *codec,
 		      struct hda_pcm *cpcm)
 {
-	static struct snd_pcm dummy_pcm;
-
 	if (cpcm->stream[SNDRV_PCM_STREAM_PLAYBACK].substreams ||
 	    cpcm->stream[SNDRV_PCM_STREAM_CAPTURE].substreams) {
 #ifdef OLD_HDA_PCM
@@ -741,7 +739,12 @@ static int attach_pcm(struct hda_bus *bus, struct hda_codec *codec,
 		}
 		pcm_streams[num_pcm_streams] = cpcm;
 #ifdef HAVE_HDA_ATTACH_PCM
-		cpcm->pcm = &dummy_pcm; /* just non-NULL */
+		cpcm->pcm = calloc(1, sizeof(*cpcm->pcm));
+		if (!cpcm->pcm) {
+			hda_log(HDA_LOG_ERR, "cannot malloc\n");
+			exit(1);
+		}
+		cpcm->pcm->device = cpcm->device;
 #endif
 	}
 	num_pcm_streams++;


More information about the Alsa-devel mailing list