Merge pull request #50 from Tahinli/dev

perf:  I was wasting first decoded samples
This commit is contained in:
Ahmet Kaan GÜMÜŞ 2024-07-28 02:12:49 +03:00 committed by GitHub
commit 3c32921458
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -211,8 +211,13 @@ async fn process_audio(
window: WindowFunction::BlackmanHarris2, window: WindowFunction::BlackmanHarris2,
}; };
let chunk_size = match decode_audio(&mut format, track_id, &mut decoder) { let (chunk_size, audio_decoded_left, audio_decoded_right) =
Some((audio_decoded_left_channel, _)) => audio_decoded_left_channel.len(), match decode_audio(&mut format, track_id, &mut decoder) {
Some((audio_decoded_left_channel, audio_decoded_right_channel)) => (
audio_decoded_left_channel.len(),
audio_decoded_left_channel,
audio_decoded_right_channel,
),
None => return, None => return,
}; };
@ -225,6 +230,14 @@ async fn process_audio(
) )
.unwrap(); .unwrap();
let (audio_resampled_left, audio_resampled_right) =
resample_audio(audio_decoded_left, audio_decoded_right, &mut resampler);
for (single_left, single_right) in audio_resampled_left.iter().zip(&audio_resampled_right) {
let _ = decoded_to_playing_sender.send(*single_left as f32);
let _ = decoded_to_playing_sender.send(*single_right as f32);
}
loop { loop {
let (mut audio_decoded_left, mut audio_decoded_right) = (vec![], vec![]); let (mut audio_decoded_left, mut audio_decoded_right) = (vec![], vec![]);