Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upAdd proper error handling, make sure sink cannot panic #138
Conversation
| let appsrc = appsrc.downcast::<AppSrc>().map_err(|_| ())?; | ||
| let appsrc = gst::ElementFactory::make("appsrc", None) | ||
| .ok_or(BackendError::ElementCreationFailed("appsrc"))?; | ||
| let appsrc = appsrc.downcast::<AppSrc>().map_err(|_| BackendError::DowncastingFailed)?; |
This comment has been minimized.
This comment has been minimized.
sdroege
Sep 28, 2018
Contributor
This is impossible to fail in this case. You create an appsrc so it will be possible to cast it
| let audio_info = gst_audio::AudioInfo::new( | ||
| gst_audio::AUDIO_FORMAT_F32, | ||
| sample_rate as u32, | ||
| channels.into(), | ||
| ).build() | ||
| .ok_or(())?; | ||
| .ok_or(BackendError::AudioInfoFailed)?; |
This comment has been minimized.
This comment has been minimized.
sdroege
Sep 28, 2018
Contributor
This also can't possibly fail. The only way how this can fail if incompatible other settings (e.g. conflicting channel positions) are given
This comment has been minimized.
This comment has been minimized.
Manishearth
Sep 28, 2018
Author
Member
This feels like it's possible to cause in a refactoring, so I'll leave this error in
| gst::Element::link_many(&[&appsrc, &resample, &convert, &sink]).map_err(|_| ())?; | ||
| .map_err(|_| BackendError::PipelineFailed)?; | ||
| gst::Element::link_many(&[&appsrc, &resample, &convert, &sink]) | ||
| .map_err(|_| BackendError::PipelineFailed)?; |
This comment has been minimized.
This comment has been minimized.
sdroege
Sep 28, 2018
Contributor
You maybe want to take the &'static str out of the error and store it in PipelineFailed
| let appsrc = appsrc.downcast::<AppSrc>().map_err(|_| ())?; | ||
| let appsrc = gst::ElementFactory::make("appsrc", None) | ||
| .ok_or(BackendError::ElementCreationFailed("appsrc"))?; | ||
| let appsrc = appsrc.downcast::<AppSrc>().map_err(|_| BackendError::DowncastingFailed)?; | ||
| Ok(Self { | ||
| pipeline: gst::Pipeline::new(None), | ||
| appsrc: Arc::new(appsrc), |
This comment has been minimized.
This comment has been minimized.
sdroege
Sep 28, 2018
Contributor
Why is the appsrc not put into the pipeline here already?
Also generally it seems like for all pipelines you're not watching their gst::Bus for messages, especially not for error messages. It would be good to add some code for that so that you can handle errors (and later possibly other things) asynchronously while the pipeline is running
This comment has been minimized.
This comment has been minimized.
ferjm
Sep 28, 2018
•
Member
Also generally it seems like for all pipelines you're not watching their gst::Bus for messages, especially not for error messages. It would be good to add some code for that so that you can handle errors (and later possibly other things) asynchronously while the pipeline is running
Yeah, we'll need that for #125, so I can take care of this for the audio sink and the player there as well.
|
Thank you for starting this! I had a half backed patch with something similar, but you beat me :) I think we need this for the audio decoder (i.e. #125) and the player as well. But we can add it in follow ups. Looks good, with @sdroege's feedback addressed and the question about the separate dummy backend crate answered. |
| @@ -2,6 +2,8 @@ extern crate ipc_channel; | |||
| #[macro_use] | |||
| extern crate serde_derive; | |||
|
|
|||
| extern crate servo_media_audio; | |||
This comment has been minimized.
This comment has been minimized.
ferjm
Sep 28, 2018
Member
Could we move the implementation of the dummy backend to a separate crate so we don't make servo_media_player depend on servo_media_audio?
This comment has been minimized.
This comment has been minimized.
Manishearth
Sep 28, 2018
Author
Member
It's hard because servo-media-audio needs the dummy backend.
However I can make the PlayerBackend trait completely separate. I'll try something.
…ency
|
Addressed |
e68840f
into
servo:master
Manishearth commentedSep 27, 2018
Not sure if the decoder side needs this
r? @ferjm