aaudio: add tests for device switch detection and refactor am: 629afae613
am: faadff3569

Change-Id: I7f62e878fd72dd706a209fe94c38998dde59945a