It's managed by the Linux kernel communicating with a user space daemon (speakersafetyd). If the user land crashes or if the user space daemon is too slow the kernel can still fall back to a ridiculously low limit that will not damage the speakers for any audio. If the kernel crashes, well you get no audio in that case. IIRC the reason they couldn't do it completely in the kernel was because the temperature model uses floating point which is not allowed in the kernel.