From dffc4d18d3a9f608f8b316f1e7057d13978ef44f Mon Sep 17 00:00:00 2001 From: Colin Guthrie Date: Tue, 17 May 2011 22:31:10 +0100 Subject: capture: Implement per-stream volume control for capture streams. This piggy backs onto the previous changes for protocol 22 and thus does not bump the version. This and the previous commits should be seen as mostly atomic. Apologies for any bisecting issues this causes (although I would expect these to be minimal) --- src/pulse/stream.c | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) (limited to 'src/pulse/stream.c') diff --git a/src/pulse/stream.c b/src/pulse/stream.c index 32936848..d60b864b 100644 --- a/src/pulse/stream.c +++ b/src/pulse/stream.c @@ -1149,7 +1149,8 @@ static int create_stream( pa_tagstruct *t; uint32_t tag; - pa_bool_t volume_set = FALSE; + pa_bool_t volume_set = !!volume; + pa_cvolume cv; uint32_t i; pa_assert(s); @@ -1246,9 +1247,18 @@ static int create_stream( PA_TAG_BOOLEAN, s->corked, PA_TAG_INVALID); - if (s->direction == PA_STREAM_PLAYBACK) { - pa_cvolume cv; + if (!volume) { + if (pa_sample_spec_valid(&s->sample_spec)) + volume = pa_cvolume_reset(&cv, s->sample_spec.channels); + else { + /* This is not really relevant, since no volume was set, and + * the real number of channels is embedded in the format_info + * structure */ + volume = pa_cvolume_reset(&cv, PA_CHANNELS_MAX); + } + } + if (s->direction == PA_STREAM_PLAYBACK) { pa_tagstruct_put( t, PA_TAG_U32, s->buffer_attr.tlength, @@ -1257,19 +1267,6 @@ static int create_stream( PA_TAG_U32, s->syncid, PA_TAG_INVALID); - volume_set = !!volume; - - if (!volume) { - if (pa_sample_spec_valid(&s->sample_spec)) - volume = pa_cvolume_reset(&cv, s->sample_spec.channels); - else { - /* This is not really relevant, since no volume was set, and - * the real number of channels is embedded in the format_info - * structure */ - volume = pa_cvolume_reset(&cv, PA_CHANNELS_MAX); - } - } - pa_tagstruct_put_cvolume(t, volume); } else pa_tagstruct_putu32(t, s->buffer_attr.fragsize); @@ -1335,6 +1332,15 @@ static int create_stream( pa_tagstruct_put_format_info(t, s->req_formats[i]); } + if (s->context->version >= 22 && s->direction == PA_STREAM_RECORD) { + pa_tagstruct_put_cvolume(t, volume); + pa_tagstruct_put_boolean(t, flags & PA_STREAM_START_MUTED); + pa_tagstruct_put_boolean(t, volume_set); + pa_tagstruct_put_boolean(t, flags & (PA_STREAM_START_MUTED|PA_STREAM_START_UNMUTED)); + pa_tagstruct_put_boolean(t, flags & PA_STREAM_RELATIVE_VOLUME); + pa_tagstruct_put_boolean(t, flags & (PA_STREAM_PASSTHROUGH)); + } + pa_pstream_send_tagstruct(s->context->pstream, t); pa_pdispatch_register_reply(s->context->pdispatch, tag, DEFAULT_TIMEOUT, pa_create_stream_callback, s, NULL); -- cgit