On Fri, 2015-09-18 at 14:47 +0200, David Henningsson wrote: > get/set balance and fade use very similar code, so refactor out > common parts. > > Signed-off-by: David Henningsson <david.henningsson at canonical.com> > --- > Â src/pulse/volume.c | 111 ++++++++++++++--------------------------------------- > Â 1 file changed, 29 insertions(+), 82 deletions(-) > > diff --git a/src/pulse/volume.c b/src/pulse/volume.c > index 69bef4f..2b34ded 100644 > --- a/src/pulse/volume.c > +++ b/src/pulse/volume.c > @@ -635,7 +635,8 @@ int pa_cvolume_compatible_with_channel_map(const pa_cvolume *v, const pa_channel > Â Â Â Â Â return v->channels == cm->channels; > Â } > Â > -static void get_avg_lr(const pa_channel_map *map, const pa_cvolume *v, pa_volume_t *l, pa_volume_t *r) { > +static void get_avg(const pa_channel_map *map, const pa_cvolume *v, pa_volume_t *l, pa_volume_t *r, > +Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â bool (*on_l)(pa_channel_position_t), bool (*on_r)(pa_channel_position_t)) { It would be nice to have a comment making it clearer that "left" and "right" in this function can also mean something else than what the words usually mean. Otherwise looks very nice. I think I thought a bit about doing this refactoring myself when working on the new volume control API, but there didn't seem to be a good way to do it; passing function pointers around didn't occur to me. --Â Tanu