mirror of
https://github.com/vlang/v.git
synced 2025-09-22 20:09:04 -04:00
examples: improve wav_player.v by ensuring the sound buffer is always zeroed (silence) first, before writing potentially incomplete frames
This commit is contained in:
parent
fe8e5495ab
commit
a5d7f36691
@ -39,10 +39,11 @@ fn play_sounds(files []string) ! {
|
||||
|
||||
//
|
||||
fn audio_player_callback(mut buffer &f32, num_frames int, num_channels int, mut p Player) {
|
||||
ntotal := num_channels * num_frames
|
||||
unsafe { vmemset(buffer, 0, ntotal * 4) }
|
||||
if p.finished {
|
||||
return
|
||||
}
|
||||
ntotal := num_channels * num_frames
|
||||
nremaining := p.samples.len - p.pos
|
||||
nsamples := if nremaining < ntotal { nremaining } else { ntotal }
|
||||
if nsamples <= 0 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user