pipeline: cleanup the start_pipeline error handling

Cleanup the code to handle GStreamer set_state
failure.
This commit is contained in:
Stéphane Cerveau 2022-01-12 18:46:07 +01:00
parent 1a8e893169
commit 0cd2490cbb

View file

@ -127,21 +127,15 @@ impl Pipeline {
self.create_pipeline(&self.render_gst_launch(graphview))
.map_err(|err| {
GPS_ERROR!("Unable to start a pipeline: {}", err);
})
.unwrap();
self.set_state(new_state)
.map_err(|_| GPS_ERROR!("Unable to change state"))
.unwrap();
} else if self.state() == PipelineState::Paused {
self.set_state(PipelineState::Playing)
.map_err(|_| GPS_ERROR!("Unable to change state"))
.unwrap();
} else {
self.set_state(PipelineState::Paused)
.map_err(|_| GPS_ERROR!("Unable to change state"))
.unwrap();
err
})?;
}
self.set_state(new_state).map_err(|error| {
GPS_ERROR!("Unable to change state {}", error);
error
})?;
Ok(self.state())
}