From: Daniel Mack <zonque@gmail.com>
To: "Paul D. DeRocco" <pderocco@ix.netcom.com>
Cc: Alsa-devel <alsa-devel@alsa-project.org>
Subject: Re: [Alsa-user] Master volume control
Date: Wed, 13 Mar 2013 18:11:25 +0100 [thread overview]
Message-ID: <5140B33D.4030406@gmail.com> (raw)
In-Reply-To: <DB754736B2E5480F987C1DE8E330AC7C@PAULD>
On 13.03.2013 17:47, Paul D. DeRocco wrote:
>> From: Clemens Ladisch [mailto:cladisch@googlemail.com]
>>
>> #include <stdio.h>
>> #include <stdlib.h>
>> #include <alsa/asoundlib.h>
>>
>> static void check(int err, const char *f)
>> {
>> if (err < 0) {
>> fprintf(stderr, "%s failed: %s\n", f,
>> snd_strerror(err));
>> exit(EXIT_FAILURE);
>> }
>> }
>> #define CHECK(f) check(f, #f)
>>
>> int main()
>> {
>> snd_ctl_t *ctl;
>> snd_ctl_elem_value_t *value;
>>
>> CHECK(snd_ctl_open(&ctl, "default", 0));
>>
>> snd_ctl_elem_value_alloca(&value);
>> snd_ctl_elem_value_set_interface(value,
>> SND_CTL_ELEM_IFACE_MIXER);
>> snd_ctl_elem_value_set_name(value, "Master Playback Volume");
>> snd_ctl_elem_value_set_integer(value, 0, 42);
>> CHECK(snd_ctl_elem_write(ctl, value));
>>
>> snd_ctl_close(ctl);
>> return 0;
>> }
>
> Well, I finally got a chance to try this. It "works", but the
> snd_ctl_elem_write call takes a couple of milliseconds (that's around a
> million instructions on my Atom), and it apparently spends this time in
> kernel state, because it causes my sound thread to underrun, so it's not
> usable.
So why are you doing this from your sound thread then?
Daniel
>
> If I use alsamixer, I don't have this problem; I can manipulate the master
> volume smoothly while I'm playing my synth app. So I went through the
> source, and found that it's using snd_mixer_selem_set_playback_volume. This
> is apparently part of something called the "Simple Mixer Interface", yet
> another section of ALSA which is completely undocumented, other than the
> Doxygen stuff (which is only meaningful as a reference for someone who
> already knows it inside out, but can't remember e.g. whether playback_pcm
> comes before or after capture_pcm in the snd_mixer_selem_regopt structure).
>
> So what's the minimum I need to do in order to get at the Master Playback
> Volume, via the Simple Mixer Interface?
>
next prev parent reply other threads:[~2013-03-13 17:11 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <B3AC1EE66F1142FF99DDC145B8669DDD@PAULD>
[not found] ` <512F0AF5.3050502@googlemail.com>
2013-03-13 16:47 ` [Alsa-user] Master volume control Paul D. DeRocco
2013-03-13 17:11 ` Daniel Mack [this message]
2013-03-13 18:39 ` Paul D. DeRocco
2013-03-13 20:17 ` Paul D. DeRocco
2013-03-14 15:10 ` Clemens Ladisch
2013-03-14 16:38 ` Paul D. DeRocco
2013-03-14 20:08 ` Clemens Ladisch
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5140B33D.4030406@gmail.com \
--to=zonque@gmail.com \
--cc=alsa-devel@alsa-project.org \
--cc=pderocco@ix.netcom.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.