summaryrefslogtreecommitdiffstats
path: root/src/pulse/volume.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2009-01-20 03:24:11 +0100
committerLennart Poettering <lennart@poettering.net>2009-01-20 03:24:11 +0100
commit936862362c30c22f42f33bd717b5f915f9c04657 (patch)
tree8d0fa97cf85001418d78e0f74312c76ee3e02da7 /src/pulse/volume.c
parent67fcc760930960b5f7494287ce3ad422de31f99c (diff)
don't divide by zero if no left resp. no right channels are defined
Diffstat (limited to 'src/pulse/volume.c')
-rw-r--r--src/pulse/volume.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/pulse/volume.c b/src/pulse/volume.c
index 9191a074..10a44daf 100644
--- a/src/pulse/volume.c
+++ b/src/pulse/volume.c
@@ -424,8 +424,15 @@ static void get_avg_lr(const pa_channel_map *map, const pa_cvolume *v, pa_volume
}
}
- *l = left / n_left;
- *r = right / n_right;
+ if (n_left <= 0)
+ *l = PA_VOLUME_NORM;
+ else
+ *l = left / n_left;
+
+ if (n_right <= 0)
+ *r = PA_VOLUME_NORM;
+ else
+ *r = right / n_right;
}
float pa_cvolume_get_balance(const pa_channel_map *map, const pa_cvolume *v) {