summaryrefslogtreecommitdiff
path: root/src/pulse/volume.c
diff options
context:
space:
mode:
authorTanu Kaskinen <tanu.kaskinen@linux.intel.com>2013-12-04 09:50:11 +0200
committerPeter Meerwald <pmeerw@pmeerw.net>2013-12-15 11:44:35 +0100
commit2747c961015ba00ec9a1cad8a8a95b4a34db9ee0 (patch)
tree4377fce703d7753da77e48daca40499f04779cd2 /src/pulse/volume.c
parenta67318f8affc4973507811946708bc17e63f1ec7 (diff)
downloadpulseaudio-2747c961015ba00ec9a1cad8a8a95b4a34db9ee0.tar.gz
Add pa_channels_valid()
I think this makes the code a bit nicer to read and write. This also reduces the chances of off-by-one errors when checking the bounds of channel count values.
Diffstat (limited to 'src/pulse/volume.c')
-rw-r--r--src/pulse/volume.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/src/pulse/volume.c b/src/pulse/volume.c
index fd67254e3..692739245 100644
--- a/src/pulse/volume.c
+++ b/src/pulse/volume.c
@@ -73,8 +73,7 @@ pa_cvolume* pa_cvolume_set(pa_cvolume *a, unsigned channels, pa_volume_t v) {
int i;
pa_assert(a);
- pa_assert(channels > 0);
- pa_assert(channels <= PA_CHANNELS_MAX);
+ pa_assert(pa_channels_valid(channels));
a->channels = (uint8_t) channels;
@@ -533,7 +532,7 @@ int pa_cvolume_valid(const pa_cvolume *v) {
pa_assert(v);
- if (v->channels <= 0 || v->channels > PA_CHANNELS_MAX)
+ if (!pa_channels_valid(v->channels))
return 0;
for (c = 0; c < v->channels; c++)