Fix a possible memory error when playing sounds.