Thread safety issues on route changes on iOS [patch included]


#1

I got some crash logs where restarting an AudioIODevice on iOS will crash if a route change was happening at the same time (or vice-versa). This was due to these events happening in separate threads. Adding locking to critical places seems to have fixed the issue. This issues seems to be happening only in iOS 9.X, so it could be that this code was just fine on older versions.

The attached patch seems to fix the issue, but I'm not 100% confident those are the best/correct places to hold the lock. Would be great if someone more familiar with the class could review and apply the patch upstream.