mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
Auto merge of #26401 - khodzha:audio-decoder-channels-indices, r=ferjm
fixed BaseAudioContext.DecodeAudioData progress callback Gstreamer backend returns channel as single bit mask (ie 1, 2, 4, 8, 32 etc). Progress callback was using this mask as plain channel index, thus storing decoded audio in wrong channel. (log2 conversion of int to int is subpar at best, but idk how to extract bit position in a clean way without a loop, any suggestions are welcome) - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes fix #25840 - [X] There are tests for these changes
This commit is contained in:
commit
ad212b23ca
1 changed files with 7 additions and 4 deletions
|
@ -481,14 +481,17 @@ impl BaseAudioContextMethods for BaseAudioContext {
|
|||
.unwrap()
|
||||
.resize(channel_count as usize, Vec::new());
|
||||
})
|
||||
.progress(move |buffer, channel_pos| {
|
||||
.progress(move |buffer, channel_pos_mask| {
|
||||
let mut decoded_audio = decoded_audio_.lock().unwrap();
|
||||
let mut channels = channels.lock().unwrap();
|
||||
let channel = match channels.entry(channel_pos) {
|
||||
let channel = match channels.entry(channel_pos_mask) {
|
||||
Entry::Occupied(entry) => *entry.get(),
|
||||
Entry::Vacant(entry) => *entry.insert(decoded_audio.len()),
|
||||
Entry::Vacant(entry) => {
|
||||
let x = (channel_pos_mask as f32).log2() as usize;
|
||||
*entry.insert(x)
|
||||
},
|
||||
};
|
||||
decoded_audio[(channel - 1) as usize].extend_from_slice((*buffer).as_ref());
|
||||
decoded_audio[channel].extend_from_slice((*buffer).as_ref());
|
||||
})
|
||||
.eos(move || {
|
||||
let _ = task_source.queue_with_canceller(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue