Compare commits

..

10 Commits

Author SHA1 Message Date
zzy
95e26f30e6 before starting pa3 2024-09-21 16:56:05 +08:00
9c5e6a449e > run 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:15:55 up 4 days, 10:21,  1 user,  load average: 0.95, 0.97, 0.79
2024-09-21 15:15:56 +08:00
85f5683da7 > 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:15:54 up 4 days, 10:21,  1 user,  load average: 0.95, 0.97, 0.79
2024-09-21 15:15:54 +08:00
3024d80c34 > run 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:11:28 up 4 days, 10:17,  1 user,  load average: 0.75, 0.69, 0.64
2024-09-21 15:11:28 +08:00
071be0f417 > 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:11:26 up 4 days, 10:17,  1 user,  load average: 0.75, 0.69, 0.64
2024-09-21 15:11:27 +08:00
c889469e86 > run 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:11:11 up 4 days, 10:16,  1 user,  load average: 0.77, 0.69, 0.64
2024-09-21 15:11:12 +08:00
fbb0a7b465 > 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:11:09 up 4 days, 10:16,  1 user,  load average: 0.77, 0.69, 0.64
2024-09-21 15:11:10 +08:00
47ade0d465 > run 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:30 up 4 days, 10:16,  1 user,  load average: 0.42, 0.62, 0.61
2024-09-21 15:10:30 +08:00
3e45705c31 > 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
2024-09-21 15:10:29 +08:00
90d3e2d60c > run 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:01:40 up 4 days, 10:07,  1 user,  load average: 0.58, 0.54, 0.54
2024-09-21 15:01:40 +08:00
2 changed files with 11 additions and 11 deletions

View File

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

View File

@ -43,7 +43,7 @@ static void audio_callback(void *userdata, uint8_t *stream, int len) {
uint32_t read_cnt = MIN(count, len);
uint32_t to_end_cnt = CONFIG_SB_SIZE - pos_read;
int32_t out_bound_cnt = read_cnt - to_end_cnt;
memset(stream, 0, len);
// memset(stream, 0, len);
if (out_bound_cnt > 0) {
memcpy(stream, sbuf + pos_read, to_end_cnt);
memcpy(stream + to_end_cnt, sbuf, out_bound_cnt);
@ -52,7 +52,7 @@ static void audio_callback(void *userdata, uint8_t *stream, int len) {
}
pos_read += read_cnt;
pos_read %= CONFIG_SB_SIZE;
// if (len > read_cnt) memset(stream + read_cnt, 0, len - read_cnt);
if (len > read_cnt) memset(stream + read_cnt, 0, len - read_cnt);
count -= read_cnt;
audio_count = count;
mtx_unlock(&mtx_audio);