Thanks to DisPlayers-Audio-Visualizers for the visualizers, Mitsuha for the AudioUnitRender hook, CustomLockscreenDuration for disabling lockscreen sleeping, and TypeStatus for the LightMessaging example
LockVisualizer has a couple of complementary features, and other things to ensure the tweak works well. These are personal preferences, as well as for practical reasons.
-
Disabling sleeping on the lockscreen when music was playing
-
Hide the music view when a notification comes up
-
Hide status bar when music view is showing
-
Move music controls from the top of the screen to closer to the home button, to allow easier access to the controls, and a more appealing visualizer
-
Change the volume slider control "thumb" from the defualt, to a much thinner version, to match the rest of the lockscreen feel
The first challange was getting the music buffer information from mediaserverd
to SpringBoard. After looking at different IPC options, I decided on mach messages becuase of the extreme speed they operate at. The AudioUnitRender function is called over eighty times a second (only brief testing has gone into this), so the data needed to get to SpringBoard in milliseconds. The second obstacle was getting the data before it was freed, but without causing any audio buffering. The solution was to have two buffers. One is copied into on the main thread, and the second is copied into on a background thread from the first buffer. This allowed the function to complete quickly enough for there to be no audio buffering, and still getting the data. After extensive testing, the largest possible audio buffer that was passed in, was 16K, so each buffer is pre-allocated with 16K and filled up as needed.