Audio issues with Mac OS

I am having audio issues with Mac OS every time I switch sound output and then switch back to Macbook speakers, which I can only resolve by restarting the Coreaudiod process. It has been like that with multiple OS X installs, and it might have happened earlier when I got my 2018 MBP. Sometimes restarting Coreaudiod is not enough, and I have to kill audio through Terminal to make it work. Anyone having the same issue?

Hey there!
Here you can find the solution and possibly the cause