ElvishArtisan/rivendell — pull request #43 by albanpeignier (2014-11-11 13:28:30+00:00)
Title: Optimize CPU usage in caed alsa playback

caed alsa takes a lot of CPU. According to CPU profiling, the `AlsaPlay2Callback` is the main candidate for optimization.

This pull request provides two optimizations :

* in Process Passthroughs, it detects when `alsa_passthrough_volume` is zero and skip the "channel".
* in Process Output Meters, it saves direct accesses in `alsa_format->card_buffer`

**Before** (about 12% of my i7 CPU) :

```
$ google-pprof --text --lines ./cae/.libs/caed profile
Using local file ./cae/.libs/caed.
Using local file profile.
Total: 316 samples
245 77.5% 77.5% 283 89.6% AlsaPlay2Callback ??:?
31 9.8% 87.3% 31 9.8% __select_nocancel /build/glibc-NmptCx/glibc-2.19/misc/../sysdeps/unix/syscall-template.S:81
23 7.3% 94.6% 30 9.5% AlsaCapture2Callback ??:?
```

**After** (about 5.5% of my i7 CPU) :

```
$ google-pprof --text --lines ./cae/.libs/caed profile_after
Using local file ./cae/.libs/caed.
Using local file profile_after.
Total: 1027 samples
405 39.4% 39.4% 775 75.5% AlsaPlay2Callback ??:?
229 22.3% 61.7% 229 22.3% __select_nocancel /build/glibc-NmptCx/glibc-2.19/misc/../sysdeps/unix/syscall-template.S:81
189 18.4% 80.1% 279 27.2% AlsaCapture2Callback ??:?
20 1.9% 82.1% 26 2.5% memset /build/glibc-NmptCx/glibc-2.19/string/../sysdeps/x86_64/memset.S:94
```