diff --git a/nemu/src/device/audio.c b/nemu/src/device/audio.c index daf83f6..cd9fbc5 100644 --- a/nemu/src/device/audio.c +++ b/nemu/src/device/audio.c @@ -30,16 +30,26 @@ enum { static uint8_t *sbuf = NULL; static uint32_t *audio_base = NULL; +// static void init_sdl_audio() { +// SDL_AudioSpec s = {}; +// s.format = AUDIO_S16SYS; // 假设系统中音频数据的格式总是使用16位有符号数来表示 +// s.userdata = NULL; // 不使用 + +// SDL_InitSubSystem(SDL_INIT_AUDIO); +// SDL_OpenAudio(&s, NULL); +// SDL_PauseAudio(0); +// } + static void audio_io_handler(uint32_t offset, int len, bool is_write) { + } void init_audio() { - uint32_t space_size = sizeof(uint32_t) * nr_reg; - audio_base = (uint32_t *)new_space(space_size); + audio_base = (uint32_t *)new_space(24); #ifdef CONFIG_HAS_PORT_IO - add_pio_map ("audio", CONFIG_AUDIO_CTL_PORT, audio_base, space_size, audio_io_handler); + add_pio_map ("audio", CONFIG_AUDIO_CTL_PORT, audio_base, 24, audio_io_handler); #else - add_mmio_map("audio", CONFIG_AUDIO_CTL_MMIO, audio_base, space_size, audio_io_handler); + add_mmio_map("audio", CONFIG_AUDIO_CTL_MMIO, audio_base, 24, audio_io_handler); #endif sbuf = (uint8_t *)new_space(CONFIG_SB_SIZE);