Skip to content

Commit

Permalink
sound/pipewire: remove duplicate increment
Browse files Browse the repository at this point in the history
For capturing, pipewire backend is incrementing the position in the
buffer, however, this is already done by write_input() thus resulting in
incrementing two times the position. This commit removes the
incrementation that happens in pipewire.

Signed-off-by: Matias Ezequiel Vara Larsen <mvaralar@redhat.com>
  • Loading branch information
MatiasVara authored and stefano-garzarella committed Mar 26, 2024
1 parent 7deb729 commit 04998a9
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions vhost-device-sound/src/audio_backends/pipewire.rs
Original file line number Diff line number Diff line change
Expand Up @@ -379,10 +379,9 @@ impl AudioBackend for PwBackend {
return;
};

let mut buf_pos = buffer.pos;
let avail = usize::try_from(buffer.desc_len())
.unwrap()
.saturating_sub(buf_pos);
.saturating_sub(buffer.pos);
let n_bytes = n_samples.min(avail);
let p = &slice[start..start + n_bytes];

Expand All @@ -394,12 +393,10 @@ impl AudioBackend for PwBackend {
break;
}

buf_pos += n_bytes;
buffer.pos = buf_pos;
n_samples -= n_bytes;
start += n_bytes;

if buf_pos >= buffer.desc_len() as usize {
if buffer.pos >= buffer.desc_len() as usize {
stream.buffers.pop_front();
}
}
Expand Down

0 comments on commit 04998a9

Please sign in to comment.