> compile NEMU

221220000 张三
Linux zzy 5.15.146.1-microsoft-standard-WSL2 #1 SMP Thu Jan 11 04:09:03 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
 15:10:28 up 4 days, 10:16,  1 user,  load average: 0.37, 0.61, 0.61
This commit is contained in:
tracer-ics2023
2024-09-21 15:10:29 +08:00
committed by zzy
parent 90d3e2d60c
commit 3e45705c31

View File

@ -10,6 +10,7 @@
static uint32_t audio_write = 0; static uint32_t audio_write = 0;
static uint32_t audio_sbuf_size; static uint32_t audio_sbuf_size;
#define MIN(a, b) ((a) < (b) ? (a) : (b))
void __am_audio_init() { void __am_audio_init() {
} }
@ -39,16 +40,15 @@ void __am_audio_play(AM_AUDIO_PLAY_T *ctl) {
while (cnt) { while (cnt) {
// lock sbuf // lock sbuf
outl(AUDIO_INIT_ADDR, 2); outl(AUDIO_INIT_ADDR, 2);
for (; i < cnt; i++) {
if (inl(AUDIO_COUNT_ADDR) == audio_sbuf_size) { int last = audio_sbuf_size - inl(AUDIO_COUNT_ADDR);
i--; int write_num = MIN(last, cnt);
break; for (int j = i; j < write_num; i ++, j ++) {
} else { outb(AUDIO_SBUF_ADDR + audio_write, ((uint8_t*)(ctl->buf.start))[i]);
outb(AUDIO_SBUF_ADDR + audio_write, ((uint8_t*)ctl->buf.start)[i]); audio_write = (audio_write + 1) % audio_sbuf_size;
audio_write = (audio_write + 1) % audio_sbuf_size;
outl(AUDIO_COUNT_ADDR, inl(AUDIO_COUNT_ADDR) + 1);
}
} }
cnt -= write_num;
outl(AUDIO_COUNT_ADDR, inl(AUDIO_COUNT_ADDR) + write_num);
// unlock sbuf // unlock sbuf
outl(AUDIO_INIT_ADDR, 0); outl(AUDIO_INIT_ADDR, 0);
} }