Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Forbid output update after EOS #833

Merged
merged 5 commits into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions compositor_pipeline/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ impl From<&UnregisterOutputError> for PipelineErrorInfo {
}

const BUILD_SCENE_ERROR: &str = "BUILD_SCENE_ERROR";
const UPDATE_AFTER_EOS: &str = "UPDATE_AFTER_EOS";

impl From<&UpdateSceneError> for PipelineErrorInfo {
fn from(err: &UpdateSceneError) -> Self {
Expand All @@ -266,6 +267,10 @@ impl From<&UpdateSceneError> for PipelineErrorInfo {
error_code: AUDIO_VIDEO_SPECIFICATION_NOT_MATCHING,
error_type: ErrorType::UserError,
},
UpdateSceneError::UpdateAfterEOS(_) => PipelineErrorInfo {
error_code: UPDATE_AFTER_EOS,
error_type: ErrorType::UserError,
},
}
}
}
Expand Down
18 changes: 18 additions & 0 deletions compositor_pipeline/src/pipeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,13 @@ impl Pipeline {
.outputs
.get(&output_id)
.ok_or_else(|| UpdateSceneError::OutputNotRegistered(output_id.clone()))?;

if let Some(cond) = &output.video_end_condition {
if cond.did_output_end() {
return Err(UpdateSceneError::UpdateAfterEOS(output_id.clone()));
noituri marked this conversation as resolved.
Show resolved Hide resolved
}
}

let (Some(resolution), Some(frame_format)) = (
output.output.resolution(),
output.output.output_frame_format(),
Expand All @@ -396,6 +403,17 @@ impl Pipeline {
output_id: &OutputId,
audio: AudioMixingParams,
) -> Result<(), UpdateSceneError> {
let output = self
.outputs
.get(output_id)
.ok_or_else(|| UpdateSceneError::OutputNotRegistered(output_id.clone()))?;

if let Some(cond) = &output.audio_end_condition {
if cond.did_output_end() {
return Err(UpdateSceneError::UpdateAfterEOS(output_id.clone()));
}
}

info!(?output_id, "Update audio mixer {:#?}", audio);
self.audio_mixer.update_output(output_id, audio)
}
Expand Down
2 changes: 1 addition & 1 deletion compositor_pipeline/src/pipeline/encoder/opus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ impl OpusEncoder {
std::thread::Builder::new()
.name("Opus encoder thread".to_string())
.spawn(move || {
let _span = span!(Level::INFO, "Opus encoder thread",).entered();
let _span = span!(Level::INFO, "Opus encoder thread").entered();
run_encoder_thread(encoder, samples_batch_receiver, packets_sender)
})
.unwrap();
Expand Down
4 changes: 4 additions & 0 deletions compositor_pipeline/src/pipeline/pipeline_output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,10 @@ impl PipelineOutputEndConditionState {
EosStatus::None
}

pub(super) fn did_output_end(&self) -> bool {
self.did_end
}

pub(super) fn on_input_registered(&mut self, input_id: &InputId) {
self.on_event(StateChange::AddInput(input_id))
}
Expand Down
3 changes: 3 additions & 0 deletions compositor_render/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ pub enum UpdateSceneError {
If audio or video was specified on register, it has to be specified in update.
If audio or video wasn't specified on register, it can't be specified in update.")]
AudioVideoNotMatching(OutputId),

#[error("Tried to update already finished output \"{0}\"")]
UpdateAfterEOS(OutputId),
}

#[derive(Debug, thiserror::Error)]
Expand Down