Skip to content

Commit

Permalink
Fix FDK AAC encoder flush panic on empty streams (#714)
Browse files Browse the repository at this point in the history
  • Loading branch information
WojciechBarczynski authored Aug 30, 2024
1 parent 358761c commit 0a2dbe3
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions compositor_pipeline/src/pipeline/encoder/fdk_aac.rs
Original file line number Diff line number Diff line change
Expand Up @@ -337,16 +337,19 @@ fn run_encoder_thread(
}
}

match encoder.flush() {
Ok(Some(encoded_samples)) => {
let send_result = packets_sender.send(EncoderOutputEvent::Data(encoded_samples));
if send_result.is_err() {
debug!("Failed to send AAC encoded samples.");
};
}
Ok(None) => {}
Err(err) => {
error!("Error flushing audio samples: {:?}", err);
// Flush encoder only if some samples were enqueued.
if encoder.start_pts.is_some() {
match encoder.flush() {
Ok(Some(encoded_samples)) => {
let send_result = packets_sender.send(EncoderOutputEvent::Data(encoded_samples));
if send_result.is_err() {
debug!("Failed to send AAC encoded samples.");
};
}
Ok(None) => {}
Err(err) => {
error!("Error flushing audio samples: {:?}", err);
}
}
}

Expand Down

0 comments on commit 0a2dbe3

Please sign in to comment.