My Macbook Pro (2016, 4 thunderbolt 3 ports) has this very annoying problem where something breaks in the audio system, and it stops playing sounds and being able to detect any output devices. It's doesn't seem to be random, but I don't know what causes it.
More specifically, it stops playing any sound whatsoever, regardless of the volume setting and which output device is selected. Then if you try plugging in a new output device in that state, it doesn't recognise it. In this state, if you try clearing audio-related caches, or rebooting coreaudio or AppleHDA, it just loses the output devices it had registered, and still can't detect new ones.
The only action that fixes the problem is reseting the NVRAM. This suggests that it's possible for the NVRAM state to become broken in a way that audio playback stops working, and new audio output devices can't be recognised anymore.
What exactly is stored in the NVRAM that could have this effect? I couldn't find any comprehensive list of what is stored in the NVRAM, instead the only things that are confirmed is that volume and screen aspect ratio are stored there. I still have some hope that by knowing this I may discover the exact actions that cause the NVRAM to get to the broken state, so that I may avoid it. Having to reset the NVRAM often is awful, since it requires a reboot.