Skip to content

Commit

Permalink
播放音频输出进度修改
Browse files Browse the repository at this point in the history
  • Loading branch information
min0911Y committed Dec 30, 2024
1 parent 8263f33 commit 8c926b1
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/kernel/test/soundtest/test-old.c
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,9 @@ void qoa_player(cstr path) {
snd->volume = 1;
vsound_open(snd);
for (int i = 0; i < qoa.samples; i += snd->bufsize / qoa.channels) {
klogd("writing %d samples", i);
vsound_write(snd, data + i * qoa.channels, snd->bufsize / qoa.channels);
printf("\r%d/%d sec", (int)((float)i / (float)qoa.samplerate),
(int)((float)qoa.samples / (float)qoa.samplerate));
printf("\r %6.2f / %.2f sec", (float)i / (float)qoa.samplerate,
(float)qoa.samples / (float)qoa.samplerate);
}
vsound_close(snd);
free(data);
Expand All @@ -175,11 +174,11 @@ void mp3_player(cstr path) {
snd->volume = 1;
vsound_open(snd);
for (int i = 0; i < samples; i += snd->bufsize / mp3.channels) {
klogd("writing %d samples", i);
vsound_write(snd, data + i * mp3.channels, snd->bufsize / mp3.channels);
printf("\r%d/%d sec", (int)((float)i / (float)mp3.sampleRate),
(int)((float)samples / (float)mp3.sampleRate));
printf("\r %6.2f / %.2f sec", (float)i / (float)mp3.sampleRate,
(float)samples / (float)mp3.sampleRate);
}
printf("\n");
vsound_close(snd);
free(data);
free(buf1);
Expand Down

0 comments on commit 8c926b1

Please sign in to comment.