Refactor audio code in client