Skip to content

Commit

Permalink
#100 better error message for vaapi init fail, don't crash
Browse files Browse the repository at this point in the history
  • Loading branch information
russelltg committed Nov 28, 2024
1 parent be86022 commit 2609fb7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
21 changes: 13 additions & 8 deletions src/cap_wlr_screencopy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,19 @@ impl Dispatch<ZwlrScreencopyFrameV1, ()> for State<CapWlrScreencopy> {
if !cap.sent_format {
cap.sent_format = true;
let device = cap.drm_device.clone();
state.negotiate_format(
&[DmabufPotentialFormat {
fourcc,
modifiers: vec![DrmModifier::LINEAR],
}],
(dmabuf_width, dmabuf_height),
device.as_deref(),
);
if state
.negotiate_format(
&[DmabufPotentialFormat {
fourcc,
modifiers: vec![DrmModifier::LINEAR],
}],
(dmabuf_width, dmabuf_height),
device.as_deref(),
)
.is_none()
{
return; // error, which has already been reported
}
}
state.on_copy_src_ready(dmabuf_width, dmabuf_height, fourcc, qhandle, capture);
}
Expand Down
4 changes: 2 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1248,7 +1248,7 @@ impl<S: CaptureSource + 'static> State<S> {
) {
Ok(enc) => enc,
Err(e) => {
eprintln!("failed to create encoder(s): {}", e);
error!("failed to create encoder(s): {}", e);
self.quit_flag.store(1, SeqCst);
return None;
}
Expand Down Expand Up @@ -1521,7 +1521,7 @@ impl EncState {

let mut hw_device_ctx = match AvHwDevCtx::new_libva(dri_device) {
Ok(hdc) => hdc,
Err(e) => bail!("Failed to load vaapi device: {e}\nThis is likely *not* a bug in wl-screenrec, but an issue with your vaapi installation. Follow your distribution's instructions. If you're pretty sure you've done this correctly, create a new issue with the output of `vainfo` and if `wf-recorder -c h264_vaapi -d /dev/dri/card0` works."),
Err(e) => bail!("Failed to load vaapi device: {e}. This is likely *not* a bug in wl-screenrec, but an issue with your vaapi installation. Follow your distribution's instructions. If you're pretty sure you've done this correctly, create a new issue with the output of `vainfo` and if `wf-recorder -c h264_vaapi -d {}` works.", dri_device.display()),
};

let mut frames_rgb = hw_device_ctx
Expand Down

0 comments on commit 2609fb7

Please sign in to comment.