From 7f767e5fe660ced7e1cb0207ef0477818152d833 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 8 May 2009 02:16:10 +0200 Subject: core: liberalize 99a6a4 a bit While flags should generally be initialized by passing them to pa_{sink|source}_new() we make an exception for the volume related flags which may be initilized afterwards, but before _put(). --- src/pulsecore/sink.c | 16 ++++++++++------ src/pulsecore/source.c | 10 +++++++--- 2 files changed, 17 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/pulsecore/sink.c b/src/pulsecore/sink.c index 0f594daf..67bdbb68 100644 --- a/src/pulsecore/sink.c +++ b/src/pulsecore/sink.c @@ -184,12 +184,6 @@ pa_sink* pa_sink_new( return NULL; } - if (!(flags & PA_SINK_HW_VOLUME_CTRL)) - flags |= PA_SINK_DECIBEL_VOLUME; - - if ((flags & PA_SINK_DECIBEL_VOLUME) && core->flat_volumes) - flags |= PA_SINK_FLAT_VOLUME; - s->parent.parent.free = sink_free; s->parent.process_msg = pa_sink_process_msg; @@ -357,6 +351,16 @@ void pa_sink_put(pa_sink* s) { pa_assert(s->rtpoll); pa_assert(s->thread_info.min_latency <= s->thread_info.max_latency); + /* Generally, flags should be initialized via pa_sink_new(). As a + * special exception we allow volume related flags to be set + * between _new() and _put(). */ + + if (!(s->flags & PA_SINK_HW_VOLUME_CTRL)) + s->flags |= PA_SINK_DECIBEL_VOLUME; + + if ((s->flags & PA_SINK_DECIBEL_VOLUME) && s->core->flat_volumes) + s->flags |= PA_SINK_FLAT_VOLUME; + s->thread_info.soft_volume = s->soft_volume; s->thread_info.soft_muted = s->muted; diff --git a/src/pulsecore/source.c b/src/pulsecore/source.c index 47bc5fb2..8aeb5606 100644 --- a/src/pulsecore/source.c +++ b/src/pulsecore/source.c @@ -174,9 +174,6 @@ pa_source* pa_source_new( return NULL; } - if (!(flags & PA_SOURCE_HW_VOLUME_CTRL)) - flags |= PA_SOURCE_DECIBEL_VOLUME; - s->parent.parent.free = source_free; s->parent.process_msg = pa_source_process_msg; @@ -311,6 +308,13 @@ void pa_source_put(pa_source *s) { pa_assert(s->rtpoll); pa_assert(s->thread_info.min_latency <= s->thread_info.max_latency); + /* Generally, flags should be initialized via pa_source_new(). As + * a special exception we allow volume related flags to be set + * between _new() and _put(). */ + + if (!(s->flags & PA_SOURCE_HW_VOLUME_CTRL)) + s->flags |= PA_SOURCE_DECIBEL_VOLUME; + s->thread_info.soft_volume = s->soft_volume; s->thread_info.soft_muted = s->muted; -- cgit