mirror of
https://github.com/pikvm/ustreamer.git
synced 2025-12-24 03:00:01 +00:00
v4p: added some checks and asserts
This commit is contained in:
parent
66572806a2
commit
ac0944ae1a
@ -158,7 +158,8 @@ int us_drm_open(us_drm_s *drm, const us_device_s *dev) {
|
||||
}
|
||||
|
||||
run->unplugged_reported = false;
|
||||
_D_LOG_INFO("Opened for %s ...", (stub == 0 ? "DMA" : "STUB"));
|
||||
run->stub = (stub > 0);
|
||||
_D_LOG_INFO("Opened for %s ...", (run->stub ? "STUB" : "DMA"));
|
||||
return stub;
|
||||
|
||||
error:
|
||||
@ -227,6 +228,8 @@ void us_drm_close(us_drm_s *drm) {
|
||||
int us_drm_wait_for_vsync(us_drm_s *drm) {
|
||||
us_drm_runtime_s *const run = drm->run;
|
||||
|
||||
assert(run->fd >= 0);
|
||||
|
||||
switch (_drm_check_status(drm)) {
|
||||
case 0: break;
|
||||
case -2: return -2;
|
||||
@ -277,7 +280,8 @@ static void _drm_vsync_callback(int fd, uint n_frame, uint sec, uint usec, void
|
||||
int us_drm_expose_stub(us_drm_s *drm, us_drm_stub_e stub, const us_device_s *dev) {
|
||||
us_drm_runtime_s *const run = drm->run;
|
||||
|
||||
assert(run->stub_n_buf >= 0);
|
||||
assert(run->fd >= 0);
|
||||
assert(run->stub);
|
||||
|
||||
switch (_drm_check_status(drm)) {
|
||||
case 0: break;
|
||||
@ -344,6 +348,15 @@ int us_drm_expose_dma(us_drm_s *drm, const us_hw_buffer_s *hw) {
|
||||
us_drm_runtime_s *const run = drm->run;
|
||||
us_drm_buffer_s *const buf = &run->bufs[hw->buf.index];
|
||||
|
||||
assert(run->fd >= 0);
|
||||
assert(!run->stub);
|
||||
|
||||
switch (_drm_check_status(drm)) {
|
||||
case 0: break;
|
||||
case -2: return -2;
|
||||
default: return -1;
|
||||
}
|
||||
|
||||
run->has_vsync = false;
|
||||
|
||||
_D_LOG_DEBUG("Exposing DMA framebuffer n_buf=%u ...", hw->buf.index);
|
||||
|
||||
@ -61,7 +61,8 @@ typedef struct {
|
||||
uint n_bufs;
|
||||
drmModeCrtc *saved_crtc;
|
||||
bool has_vsync;
|
||||
int stub_n_buf;
|
||||
bool stub;
|
||||
uint stub_n_buf;
|
||||
us_frametext_s *ft;
|
||||
bool unplugged_reported;
|
||||
} us_drm_runtime_s;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user