aboutsummaryrefslogtreecommitdiffstats
path: root/pulse.cc
diff options
context:
space:
mode:
authorDave Reisner <dreisner@archlinux.org>2013-01-03 14:36:46 -0500
committerDave Reisner <dreisner@archlinux.org>2013-01-03 14:36:46 -0500
commitf374fb2792f5a9fb0aefe4dd1387b2bdace418b3 (patch)
tree5ba893a677b8f6054c017b1a2d900ab1bd53a3e9 /pulse.cc
parent130d9bbe6fa59404f71536fd9e7e97f2cdf05b14 (diff)
downloadmirror-ponymix-f374fb2792f5a9fb0aefe4dd1387b2bdace418b3.tar.gz
mirror-ponymix-f374fb2792f5a9fb0aefe4dd1387b2bdace418b3.tar.bz2
mirror-ponymix-f374fb2792f5a9fb0aefe4dd1387b2bdace418b3.zip
properly clamp values in Set{Balance,Volume}
Diffstat (limited to 'pulse.cc')
-rw-r--r--pulse.cc14
1 files changed, 6 insertions, 8 deletions
diff --git a/pulse.cc b/pulse.cc
index c423c72..0488717 100644
--- a/pulse.cc
+++ b/pulse.cc
@@ -342,6 +342,7 @@ bool PulseClient::SetVolume(Device& device, long volume) {
return false;
}
+ volume = volume_range_.Clamp(volume);
const pa_cvolume *cvol = value_to_cvol(volume, &device.volume_);
pa_operation* op = device.ops_.SetVolume(context_,
device.index_,
@@ -357,13 +358,11 @@ bool PulseClient::SetVolume(Device& device, long volume) {
}
bool PulseClient::IncreaseVolume(Device& device, long increment) {
- return SetVolume(device,
- volume_range_.Clamp(device.volume_percent_ + increment));
+ return SetVolume(device, device.volume_percent_ + increment);
}
bool PulseClient::DecreaseVolume(Device& device, long increment) {
- return SetVolume(device,
- volume_range_.Clamp(device.volume_percent_ - increment));
+ return SetVolume(device, device.volume_percent_ - increment);
}
bool PulseClient::SetBalance(Device& device, long balance) {
@@ -374,6 +373,7 @@ bool PulseClient::SetBalance(Device& device, long balance) {
return false;
}
+ balance = balance_range_.Clamp(balance);
pa_cvolume *cvol = pa_cvolume_set_balance(&device.volume_,
&device.channels_,
balance / 100.0);
@@ -391,13 +391,11 @@ bool PulseClient::SetBalance(Device& device, long balance) {
}
bool PulseClient::IncreaseBalance(Device& device, long increment) {
- return SetBalance(device,
- balance_range_.Clamp(device.balance_ + increment));
+ return SetBalance(device, device.balance_ + increment);
}
bool PulseClient::DecreaseBalance(Device& device, long increment) {
- return SetBalance(device,
- balance_range_.Clamp(device.balance_ - increment));
+ return SetBalance(device, device.balance_ - increment);
}
int PulseClient::GetVolume(const Device& device) const {