[pulseaudio-discuss] cannot set volume in c++

Tanu Kaskinen tanuk at iki.fi
Sun Jun 5 12:02:48 UTC 2016


On Sun, 2016-06-05 at 10:16 +0200, pfl wrote:
> hello everyone,
> 
> for a raspberrry applicance I need to setup the input volume of the 
> microphone programaticaly
> 
> in c++, I can read the actual value (changed if I change it in the pa 
> mixer), but as I set it, it does not seem to work...
> 
> after I launched my code, I check in the pa panel mixer, the volume is 
> not changed
> 
> below, the sources with their chanels and volumes
> 
> > SOURCE 
> :[0]'alsa_output.usb-0d8c_C-Media_USB_Headphone_Set-00-Set.analog-stereo.monitor''Monitor 
> of Audio Adapter Analog Stereo'(0)=65536(1)=65536SOURCE 
> :[1]'alsa_input.usb-0d8c_C-Media_USB_Headphone_Set-00-Set.analog-mono''Audio 
> Adapter Analog Mono'(0)=26281SOURCE 
> :[2]'alsa_output.0.analog-stereo.monitor''Monitor of bcm2835 ALSA Analog 
> Stereo'(0)=65536(1)=65536|
> 
> so I try to change volume of source index #1
> 
> > voidsetVolume(intindex,intvolume){pa_operation*o;currentVolume.values[0]=volume;if(!(o 
> =pa_context_set_source_output_volume(context,index,¤tVolume,NULL,NULL))){printf("pa_context_set_source_output_volume() 
> failed");return;}printf("new volume: 
> %d\n",currentVolume.values[0]);pa_operation_unref(o);}|
> 
> please can someone help ?

(For future reference: avoid sending HTML mail, at least to mailing
lists. The HTML formatting tends to get lost. Your mail application
should have an option to select "plain text" for outgoing mail. You can
see how your mail looks to me in the above quoted text, and also in the
mailing list archive here:
https://lists.freedesktop.org/archives/pulseaudio-discuss/2016-June/026338.html )

The problem is that you set the volume for a "source output" rather
than for a "source". A source output means a recording stream, while a
source is a device such as a microphone. Use
pa_context_set_source_volume_by_index() or
pa_context_set_source_volume_by_name().

-- 
Tanu


More information about the pulseaudio-discuss mailing list