![]() |
/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. |
Re: /dev/mixer on N900 ?
Quote:
Code:
amixer -c 0 sset "Speaker Function" Off Code:
amixer -c 0 sset "Earphone Function" On |
Re: /dev/mixer on N900 ?
Quote:
Thank you for your help. amixer is a system command ? How to call system command from application ? Thanks |
Re: /dev/mixer on N900 ?
Quote:
|
Re: /dev/mixer on N900 ?
Quote:
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. |
Re: /dev/mixer on N900 ?
Quote:
|
Re: /dev/mixer on N900 ?
Quote:
|
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. |
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. |
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