Skip to content

Commit

Permalink
soxresampler: return nullptr when empty (#448)
Browse files Browse the repository at this point in the history
  • Loading branch information
theomonnom authored Sep 28, 2024
1 parent 1ee55b1 commit dd5cb7e
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions livekit-ffi/src/server/requests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -719,11 +719,21 @@ fn on_push_sox_resampler(

let mut resampler = resampler.lock();
match resampler.push(data) {
Ok(output) => Ok(proto::PushSoxResamplerResponse {
output_ptr: output.as_ptr() as u64,
size: (output.len() * std::mem::size_of::<i16>()) as u32,
..Default::default()
}),
Ok(output) => {
if output.is_empty() {
return Ok(proto::PushSoxResamplerResponse {
output_ptr: 0,
size: 0,
..Default::default()
});
}

Ok(proto::PushSoxResamplerResponse {
output_ptr: output.as_ptr() as u64,
size: (output.len() * std::mem::size_of::<i16>()) as u32,
..Default::default()
})
}
Err(e) => {
Ok(proto::PushSoxResamplerResponse { error: Some(e.to_string()), ..Default::default() })
}
Expand Down

0 comments on commit dd5cb7e

Please sign in to comment.