maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Development (https://talk.maemo.org/forumdisplay.php?f=13)
-   -   /dev/mixer on N900 ? (https://talk.maemo.org/showthread.php?t=61130)

verrnum 2010-08-26 14:15

/dev/mixer on N900 ?
 
hi,

i found an N800 example code to unmute / mute sound of mixer.

The mixer device is referenced in /dev/mixer.

But when i look for /dev/mixer in N900 device, i didn't find it.

Is it normal ?

Thanks for your help.

pospani 2010-08-28 05:41

Re: /dev/mixer on N900 ?
 
Quote:

Originally Posted by verrnum (Post 799095)
hi,

i found an N800 example code to unmute / mute sound of mixer.

The mixer device is referenced in /dev/mixer.

But when i look for /dev/mixer in N900 device, i didn't find it.

Is it normal ?

Thanks for your help.

You can mute/unmute sound simply by calling:
Code:

amixer -c 0 sset "Speaker Function" Off
amixer -c 0 sset "Speaker Function" On

You also can route all sound to Earphone by:
Code:

amixer -c 0 sset "Earphone Function" On
amixer -c 0 sset "Earphone" 118
amixer -c 0 sset "Mono DAC" 118
amixer -c 0 sset "Right DAC_R1 Mixer Mono" on
amixer -c 0 sset "Left DAC_L1 Mixer Mono" on
amixer -c 0 sset "Speaker Function" Off


verrnum 2010-08-28 21:16

Re: /dev/mixer on N900 ?
 
Quote:

Originally Posted by pospani (Post 800577)
You can mute/unmute sound simply by calling:
Code:

amixer -c 0 sset "Speaker Function" Off
amixer -c 0 sset "Speaker Function" On

You also can route all sound to Earphone by:
Code:

amixer -c 0 sset "Earphone Function" On
amixer -c 0 sset "Earphone" 118
amixer -c 0 sset "Mono DAC" 118
amixer -c 0 sset "Right DAC_R1 Mixer Mono" on
amixer -c 0 sset "Left DAC_L1 Mixer Mono" on
amixer -c 0 sset "Speaker Function" Off


Hi,

Thank you for your help.

amixer is a system command ? How to call system command from application ?

Thanks

digitalvoid 2010-08-28 21:23

Re: /dev/mixer on N900 ?
 
Quote:

Originally Posted by pospani (Post 800577)
You can mute/unmute sound simply by calling:
Code:

amixer -c 0 sset "Speaker Function" Off
amixer -c 0 sset "Speaker Function" On

You also can route all sound to Earphone by:
Code:

amixer -c 0 sset "Earphone Function" On
amixer -c 0 sset "Earphone" 118
amixer -c 0 sset "Mono DAC" 118
amixer -c 0 sset "Right DAC_R1 Mixer Mono" on
amixer -c 0 sset "Left DAC_L1 Mixer Mono" on
amixer -c 0 sset "Speaker Function" Off


What are the red audio sources?

pospani 2010-08-29 06:32

Re: /dev/mixer on N900 ?
 
Quote:

Originally Posted by verrnum (Post 800963)
Hi,

Thank you for your help.

amixer is a system command ? How to call system command from application ?

Thanks


From Qt you can use QProcess to execute external processes.
If you dont want do this by starting amixer from within your application, you must use ALSA libraries to accomplish this.
But believe me, it is much easier to call amixer as external process.

pospani 2010-08-29 06:38

Re: /dev/mixer on N900 ?
 
Quote:

Originally Posted by digitalvoid (Post 800973)
What are the red audio sources?

All audio sources are routed. For example you can route audio output from mediaplayer to the earphone. But it makes no sense, routing audio to earphone is needed for VOIP applications, usually you want to hear the other voice out of the earphone and not from external speakers. By using this commands you can switch between earphone and external speaker.

verrnum 2010-08-29 09:39

Re: /dev/mixer on N900 ?
 
Quote:

Originally Posted by pospani (Post 801188)
From Qt you can use QProcess to execute external processes.
If you dont want do this by starting amixer from within your application, you must use ALSA libraries to accomplish this.
But believe me, it is much easier to call amixer as external process.

Thank for hints.

dannym 2010-08-29 17:35

Re: /dev/mixer on N900 ?
 
verrnum, Yes, "/dev/mixer" is the device the rest of the world uses for OpenSoundSystem audio on UNIX and UNIX-like systems.

However, because of licensing problems in the past (OSS went closed source for a time), Linux has developed its own audio subsystem called "Advanced Linux Sound Architecture" to replace it.
Nowadays, there's also a daemon called "pulseaudio" which does software mixing and per-application mixing etc.

Note that ALSA exposes some rather un-UNIXish API which everyone is supposed to use. One is not supposed to even open the device files (there are device files for ALSA, foo).
To understand the ALSA API, forget everything you thought you knew about UNIX device access and rather think about something like DirectSound or WinMM (I'm not a fan, but that's just how it is).

I think PulseAudio has an ALSA-lib interface, so when you use the ALSA libs to set something, you actually talk to PulseAudio.

Confused yet?

I've extracted the relevant bits of the Xfce4 mixer I wrote 7 years ago:

#include <alsa/asoundlib.h>
#include <alsa/mixer.h>
#include <alsa/control.h>

static char const* master_ids[MAX_MASTERS] = {
"Master",
"PCM",
"Analog Front",
"Speaker",
NULL,
};

static snd_mixer_t *handle = NULL;
static snd_mixer_elem_t *elem = NULL;
static char card[64] = "default";
snd_mixer_selem_id_t* master_selectors[MAX_MASTERS] = { NULL };

if ((err = snd_mixer_open(&handle, 0)) < 0 || !handle) {
printf("alsa: Mixer %s open error: %s\n", card, snd_strerror(err));
return;
}

if ((err = snd_mixer_attach(handle, card)) < 0) {
snd_mixer_close(handle);
return;
}
if ((err = snd_mixer_selem_register(handle, NULL, NULL)) < 0) {
printf("alsa: Mixer register error: %s\n", snd_strerror(err));
snd_mixer_close(handle);
return;
}
err = snd_mixer_load(handle);
if (err < 0) {
printf("alsa: Mixer load error: %s: %s\n", card, snd_strerror(err));
snd_mixer_close(handle);
handle = NULL;
return;
}

for (i = 0; elem == NULL && i < MAX_MASTERS && master_ids[i] != NULL; i++) {
snd_mixer_selem_id_alloca(&master_selectors[i]);
snd_mixer_selem_id_set_index(master_selectors[i], 0);
snd_mixer_selem_id_set_name(master_selectors[i], master_ids[i]);

elem = snd_mixer_find_selem(handle, master_selectors[i]);

if (elem != NULL) {
if (!snd_mixer_selem_has_common_volume(elem)
&& !snd_mixer_selem_has_playback_volume(elem)
) { /* no playback device */
elem = NULL;
}
}

snd_mixer_selem_set_playback_volume_all (elem, lval);

See for yourself at http://archive.ubuntu.com/ubuntu/poo...97.orig.tar.gz in file "lib/vc_alsa.c".

The platform part one is supposed to use on Maemo (I think) is http://www.gstreamer.net/data/doc/gstreamer/head/pwg/html/section-iface-mixer.html and it's used like this: https://launchpad.net/gmixer

P.S.: can someone please fix indentation in talk.maemo.org posts? Code samples are almost unreadable like this.

verrnum 2010-08-29 20:36

Re: /dev/mixer on N900 ?
 
Thank you for your very complete answer :)

I am still a newby developper in linux plateform, and it's a little bit difficult too understand all your explaination.

I will user the amixer command via QProcess :D.

Thanks a lot.

lauksas 2011-03-18 22:47

Re: /dev/mixer on N900 ?
 
hi all,
I don't know if I had to open another thread to ask this... but still...
taking this scenario:
I'm in a call on the n900, and I want to show a music or any sound provided from the music player for me and the person that I'm calling.
Like we hear the same podcast, or show any track that I did.
Can I do this with the amixer command?


All times are GMT. The time now is 07:35.

vBulletin® Version 3.8.8