[pulseaudio-discuss] [PATCH 1/6] stream: Add a pa_stream_set_volume() API
Tanu Kaskinen
tanuk at iki.fi
Mon Feb 29 12:27:54 UTC 2016
On Tue, 2015-12-29 at 09:03 +0530, arun at accosted.net wrote:
> @@ -1286,14 +1287,19 @@ static int create_stream(
> PA_TAG_BOOLEAN, s->corked,
> PA_TAG_INVALID);
>
> - if (!volume) {
> + if (volume) {
> + s->volume = *volume;
> + s->volume_set = true;
> + }
I'd prefer not to save the initial volume. I don't see the need for it,
and it means that s->volume has different semantics depending on the
stream state: at one point it's the client's requested volume, and at
another point it's the server-assigned volume.
If we do allow calling pa_stream_set_volume() before connecting the
stream and save the initial requested volume in s->volume, it should be
documented what happens in this sequence:
pa_stream_set_volume();
pa_stream_connect_playback(volume=NULL);
Currently the documentation says that giving NULL volume to
pa_stream_connect_playback() results in the default volume being
assigned for the stream, but this patch changes that.
> +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);
> + 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? */
No, I don't think it makes sense to support setting volume for sample
uploads.
--
Tanu
More information about the pulseaudio-discuss
mailing list