[PATCH v2] sink-input, source-output: Fix mute saving

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



"i->save_muted = i->save_muted || mute" makes no sense. The intention
was most likely to use "save" instead of "mute" in the assignment.
This line originates from reverting the volume ramping code, commit
8401572fd534f10e07ed6a418e1399b1294d5596.

The idea of "i->save_muted |= save" is that even if the mute state
doesn't change, save_muted should still be updated, but only if the
transition is from "don't save" to "save".

Changing "!i->muted == !mute" to "mute == i->muted" is cosmetic only.
The rationale behind the old form was probably that when we still had
pa_bool_t, booleans could in theory be defined as int, so comparing
the values without the ! operator was not entirely safe. That's
unnecessary now that we use the standard bool type, which can only
have values 0 or 1.
---
 src/pulsecore/sink-input.c    | 4 ++--
 src/pulsecore/source-output.c | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/pulsecore/sink-input.c b/src/pulsecore/sink-input.c
index fb2a893..295a8d0 100644
--- a/src/pulsecore/sink-input.c
+++ b/src/pulsecore/sink-input.c
@@ -1414,8 +1414,8 @@ void pa_sink_input_set_mute(pa_sink_input *i, bool mute, bool save) {
     pa_assert_ctl_context();
     pa_assert(PA_SINK_INPUT_IS_LINKED(i->state));
 
-    if (!i->muted == !mute) {
-        i->save_muted = i->save_muted || mute;
+    if (mute == i->muted) {
+        i->save_muted |= save;
         return;
     }
 
diff --git a/src/pulsecore/source-output.c b/src/pulsecore/source-output.c
index 4e4b7e9..34a4cb0 100644
--- a/src/pulsecore/source-output.c
+++ b/src/pulsecore/source-output.c
@@ -1061,8 +1061,8 @@ void pa_source_output_set_mute(pa_source_output *o, bool mute, bool save) {
     pa_assert_ctl_context();
     pa_assert(PA_SOURCE_OUTPUT_IS_LINKED(o->state));
 
-    if (!o->muted == !mute) {
-        o->save_muted = o->save_muted || mute;
+    if (mute == o->muted) {
+        o->save_muted |= save;
         return;
     }
 
-- 
1.8.3.1



[Index of Archives]     [Linux Audio Users]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux