togglerecord: define total order on mutexes
I'm tracking a bug which may or may not be related to a deadlock in togglerecord.
I audited the code and figured we could define a total order on the mutexes with just a few changes. I don't know yet if that will help with my bug but it can't hurt to have a order properly documented with so many mutexes involved.