My Mac is a MacBook M1Max, and I have encountered a sporadic problem in the past few months. The headphone volume is expected, but the built-in speaker volume is very low, and it is entirely inaudible. After restarting the Mac, it will be completely back to normal.
