14 Commits
Author SHA1 Message Date
Dan McGee db8b181038 hairtunes: implement a simple LCG-based RNG for dithering
We are calling out to libc's rand() function, which has significant
overhead, especially since we are calling it 88200 times per second
(2 channels * 44100 samples).

Implement a very simple linear congruential generator in our code that
is plenty good enough for dithering purposes, and small enough for the
compiler to optimize and inline.
2012-02-25 13:57:46 -06:00
Dan McGee fa95439b98 hairtunes: simplify and reorganize some floating point operations
The math operations are all equivalent, but are simplified a bit for the
benefit of processors with slower floating point performance.

* Don't use float casts when we need to eventually convert to double
  precision anyway.
* Use multiplication instead of division when possible.
2012-02-25 13:55:38 -06:00
Dan McGee b5a91cbebd Tabs to spaces conversion 2012-02-24 16:15:21 -06:00
Dan McGee 59d26d3a7c Use static where appropriate in shairport.c
Most functions don't need to be public outside of this file, so move all
the forward declarations out of shairport.h.
2012-02-24 16:14:43 -06:00
Dan McGee 435a866816 Add static to some functions in alac.c 2012-02-24 16:02:47 -06:00
Dan McGee 0b4c7ad4be hairplay: various small code cleanups 2012-02-24 15:53:30 -06:00
Dan McGee cd957048cb Use the audio buffer mutex appropriately
We need to use this any time we write to or access any of the
audio-buffer related variables. This also removes the need to use
'volatile', which cripples the compiler optimizations.
2012-02-24 15:53:28 -06:00
Dan McGee 8b1728d946 Use a pthread mutex around the volume settings
Using the `volatile` qualifier in multithreading code is never the right
answer. Mutexes should be used as was attempted with the audio buffer
code. Here, we implement a new mutex for the volume and fix_volume
globals, and grab a lock on it when necessary, which is for both reads
and writes.
2012-02-24 15:52:54 -06:00
Dan McGee 0a446a421d Return the correct value from biquad_filt()
If you turned set `debug = 1` in hairtunes, you'd quickly get a mess of
debug messages that showed bf_est_drift in bf_est_update() going quicky
out of range toward a float NaN value (usually negative). Clearly the
presence of this `out` variable in biquad_filt was meant to be used, not
marked as unused.
2012-02-24 15:52:54 -06:00
Dan McGee 74ed9c6fa2 hairtunes: use static keyword appropriately
This allows the compiler to do a much better job on this file, as it
currently can't inline most of the functions because they are
technically visible outside the file. Mark most functions and variables
static to let the compiler work.
2012-02-24 15:52:53 -06:00
Dan McGee 565b223bb0 Don't require extern usage of frame buffering value
This makes things a bit cleaner and easier to grasp.
2012-02-24 14:33:05 -06:00
Dan McGee 82e7cf8490 Fix dependency issue in Makefile
Make the dependency and compile command match in the resources used.
2012-02-24 14:24:10 -06:00
Dan McGee 7fcfd3ddac Small socketlib static and return value tweaks 2012-02-24 14:17:30 -06:00
Dan McGee f5e7e87c51 Remove dead code in alac.c 2012-02-24 14:13:23 -06:00