From: Takashi Iwai Subject: Re: How to select between mixer route elements? Date: Tue, 02 May 2006 14:18:29 +0200 Message-ID: References: <44568648.9040902@cc.jyu.fi> Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Return-path: In-Reply-To: <44568648.9040902@cc.jyu.fi> Sender: alsa-devel-admin@lists.sourceforge.net Errors-To: alsa-devel-admin@lists.sourceforge.net List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , List-Archive: To: lamikr Cc: alsa-devel@lists.sourceforge.net List-Id: alsa-devel@alsa-project.org At Tue, 02 May 2006 01:06:00 +0300, lamikr wrote: > > Hi > > I am working with the tsc2101 alsa sound driver for the iPAQ h6300 and > userspace phone application called gomunicator for that. > For the tsc2101 mixer I have creted an element "Playback Playback Route" The name sounds strange. Isn't it "Playback Route"? > which is currently initalized to be a enumerated element > in a following way. > > static char *texts[PLAYBACK_TARGET_COUNT] = { > "Loudspeaker", "Headphone", "Cellphone" > }; > uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; > > The idea is following. If I/user want to play music or record by using > normal speaker and mic I need to select "Loudspeaker" > as a playback target. If I instead want to use headphone for that > purpose I need to select Headphone. And when I want to have a phone call > (this iPAQ module has gsm phone) I route tsc2101 to handle gsm module by > selecting "Cellphone". > > The problem is that currently I need to use alsa-mixer before I make the > phone calls which is kind of not very handy. > So to get Tux finally a call home properly I should do something like > this from the userspace: > > old_selection = get_current_playback_route_selection(), > select_playback_route("Cellphone"); > make_call() > end_call() > select_playback_route(old_selection) It can be easily done via PCM hooks plugin. The hooks plugin can set up the mixer controls after opening a slave PCM device. For example, "cellphone" PCM below will automatically change "Playback Route" control to "Cellphone" and keep while it's opened, then revert to the old value after closed. pcm.cellphone { type hooks slave.pcm "hw:0" hooks.0 { type ctl_elems hook_args [ { name "Playback Route" lock true preverve true value "Cellphone" } ] } } > To implement the currently selected route item, I have tried following > > static int *old_playback_item; > ... > snd_mixer_selem_id_set_name (sid, "Playback"); > if (elem_playback) { > printf("Playback found\n"); > if (snd_mixer_selem_is_enumerated(elem_playback)) { > printf("Playback is enumerated\n"); > //snd_mixer_selem_get_enum_item(handle, 0, old_playback_item); > printf("index fo the selected playback item = %d\n", > *old_playback_item); > } > } > > but this fails for me giving a following error to output: > > Playback found > Playback is enumerated > gomunicator: simple.c:1969: snd_mixer_selem_get_enum_item: Assertion > `elem->type == SND_MIXER_ELEM_SIMPLE' failed. This is likely a conflict of name space of "Playback" controls. Do you have other controls with "Playback XXX"? Takashi ------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642