[pulseaudio-discuss] [PATCH 1/6] stream: Add a pa_stream_set_volume() API

Tanu Kaskinen tanuk at iki.fi
Mon Feb 29 12:53:24 UTC 2016


A couple more comments...

On Tue, 2015-12-29 at 09:03 +0530, arun at accosted.net wrote:
> +int pa_stream_set_volume(pa_stream *s, pa_cvolume *v, pa_stream_success_cb_t cb, void *userdata) {
> +    pa_operation *o;
> +    pa_tagstruct *t;
> +    uint32_t tag;
> +
> +    pa_assert(s);
> +    pa_assert(v);
> +    pa_assert(PA_REFCNT_VALUE(s) >= 1);
> +
> +    PA_CHECK_VALIDITY(s->context, !pa_detect_fork(), PA_ERR_FORKED);
> +    PA_CHECK_VALIDITY(s->context, s->state != PA_STREAM_FAILED && s->state != PA_STREAM_TERMINATED, PA_ERR_BADSTATE);

s->state has to be PA_STREAM_READY, because the function depends on
having s->sample_spec and s->stream_index initialized.

> +    PA_CHECK_VALIDITY(s->context, userdata == NULL || cb != NULL, PA_ERR_INVALID);
> +    PA_CHECK_VALIDITY(s->context, s->direction != PA_STREAM_UPLOAD, PA_ERR_INVALID); /* TODO: do we want to support this? */
> +    PA_CHECK_VALIDITY(s->context, pa_cvolume_valid(v), PA_ERR_INVALID);
> +    PA_CHECK_VALIDITY(s->context, pa_cvolume_compatible(v, &s->sample_spec), PA_ERR_INVALID);

If the volume has only one channel, it should be always accepted. It
would be also good to document this in the header.

-- 
Tanu


More information about the pulseaudio-discuss mailing list