Code refactoring for audio resource logic