Fixed a segfault bug in audio generation code