Skip to content

Commit 3ce9c63

Browse files
committed
fix(mixer): ensure correct channel alignment for pending sources
1 parent 603e258 commit 3ce9c63

1 file changed

Lines changed: 9 additions & 13 deletions

File tree

src/mixer.rs

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -168,21 +168,17 @@ impl Iterator for MixerSource {
168168
}
169169

170170
impl MixerSource {
171-
// Samples from the #next() function are interlaced for each of the channels.
172-
// We need to ensure we start playing sources so that their samples are
173-
// in-step with the modulo of the samples produced so far. Otherwise, the
174-
// sound will play on the wrong channels, e.g. left / right will be reversed.
171+
// Samples from the `next()` function are interlaced for each of the channels.
172+
// New sources are held in `still_pending` until a frame boundary so their
173+
// samples stay in-step with the channel layout. Otherwise the sound will
174+
// play on the wrong channels, e.g. left / right will be reversed.
175175
fn start_pending_sources(&mut self) {
176176
while let Ok(source) = self.pending_rx.try_recv() {
177-
// Only start sources at frame boundaries (when current_channel == 0)
178-
// to ensure correct channel alignment
179-
let in_step = self.current_channel == 0;
180-
181-
if in_step {
182-
self.current_sources.push(source);
183-
} else {
184-
self.still_pending.push(source);
185-
}
177+
self.still_pending.push(source);
178+
}
179+
180+
if self.current_channel == 0 {
181+
self.current_sources.append(&mut self.still_pending);
186182
}
187183
}
188184

0 commit comments

Comments
 (0)