diff --git a/nemu/src/device/audio.c b/nemu/src/device/audio.c index 11fe2c9..0fb22f1 100644 --- a/nemu/src/device/audio.c +++ b/nemu/src/device/audio.c @@ -38,15 +38,16 @@ static void audio_callback(void *userdata, uint8_t *stream, int len) { uint32_t read_cnt = MIN(count, len); uint32_t to_end_cnt = audio_base[reg_sbuf_size] - pos_read; int32_t out_bound_cnt = read_cnt - to_end_cnt; + memset(stream, 0, len); if (out_bound_cnt > 0) { - SDL_memcpy(stream, sbuf + pos_read, to_end_cnt); - SDL_memcpy(stream + to_end_cnt, sbuf, out_bound_cnt); + memcpy(stream, sbuf + pos_read, to_end_cnt); + memcpy(stream + to_end_cnt, sbuf, out_bound_cnt); } else { - SDL_memcpy(stream, sbuf + pos_read, read_cnt); + memcpy(stream, sbuf + pos_read, read_cnt); } pos_read += read_cnt; pos_read %= audio_base[reg_sbuf_size]; - if (len > read_cnt) SDL_memset(stream + read_cnt, 0, len - read_cnt); + // if (len > read_cnt) memset(stream + read_cnt, 0, len - read_cnt); audio_base[reg_count] -= read_cnt; }