[pulseaudio-discuss] pa_context_set_source_volume_by_index() failed

Tanu Kaskinen tanuk at iki.fi
Wed Oct 26 16:41:35 UTC 2016


On Tue, 2016-10-25 at 19:13 +0200, pfl wrote:
> hi,
> 
> I try to set the volume on source #0 (the audio jack of my raspbery pi) 
> but it does not work

There may be some confusion about the terminology. The audio jack on
Raspberry Pi is only for output, and "sources" in pulseaudio are for
recording input. I would guess that you're actually trying to set the
playback volume, so you're interested in the "sink" volume, not the
"source" volume.

>      void setVolume(int index,int volume)  // where index is 0
>      {
>          pa_operation* o;
>          currentVolume.values[0]=volume;
>          if (!(o = pa_context_set_source_volume_by_index(context, index, 
> &currentVolume, NULL/*volumeCallback*/, NULL)))
>          {
>              printf("pa_context_set_source_volume_by_index() failed\n");

You didn't say this explicitly, but from the mail subject I guess
pa_context_set_source_volume_by_index() returned NULL. That can happen
if currentVolume is invalid (you don't show how it's initialized, so I
don't know if this is the case), or if the connection to the server is
not yet ready or the connection has terminated. To debug this, you can
query the connection state with pa_context_get_state().

-- 
Tanu

https://www.patreon.com/tanuk


More information about the pulseaudio-discuss mailing list