From 4f7ce91e7fe4d95671a3a217d4f7b1a98a56b4aa Mon Sep 17 00:00:00 2001 From: Quantum Date: Fri, 13 Aug 2021 19:30:41 -0400 Subject: [PATCH] [host] capture: switch all asserts to DEBUG_ASSERT --- host/platform/Linux/capture/XCB/src/xcb.c | 17 +++++++------- host/platform/Windows/capture/DXGI/src/dxgi.c | 23 +++++++++---------- .../Windows/capture/NVFBC/src/nvfbc.c | 1 - 3 files changed, 19 insertions(+), 22 deletions(-) diff --git a/host/platform/Linux/capture/XCB/src/xcb.c b/host/platform/Linux/capture/XCB/src/xcb.c index a36754c1..d38861a2 100644 --- a/host/platform/Linux/capture/XCB/src/xcb.c +++ b/host/platform/Linux/capture/XCB/src/xcb.c @@ -23,7 +23,6 @@ #include "common/debug.h" #include "common/event.h" #include -#include #include #include #include @@ -64,7 +63,7 @@ static const char * xcb_getName(void) static bool xcb_create(CaptureGetPointerBuffer getPointerBufferFn, CapturePostPointerBuffer postPointerBufferFn) { - assert(!this); + DEBUG_ASSERT(!this); this = (struct xcb *)calloc(sizeof(struct xcb), 1); this->shmID = -1; this->data = (void *)-1; @@ -82,8 +81,8 @@ static bool xcb_create(CaptureGetPointerBuffer getPointerBufferFn, CapturePostPo static bool xcb_init(void) { - assert(this); - assert(!this->initialized); + DEBUG_ASSERT(this); + DEBUG_ASSERT(!this->initialized); lgResetEvent(this->frameEvent); @@ -134,7 +133,7 @@ fail: static bool xcb_deinit(void) { - assert(this); + DEBUG_ASSERT(this); if ((uintptr_t)this->data != -1) { @@ -167,8 +166,8 @@ static void xcb_free(void) static CaptureResult xcb_capture(void) { - assert(this); - assert(this->initialized); + DEBUG_ASSERT(this); + DEBUG_ASSERT(this->initialized); if (!this->hasFrame) { @@ -211,8 +210,8 @@ static CaptureResult xcb_waitFrame(CaptureFrame * frame, static CaptureResult xcb_getFrame(FrameBuffer * frame, const unsigned int height, int frameIndex) { - assert(this); - assert(this->initialized); + DEBUG_ASSERT(this); + DEBUG_ASSERT(this->initialized); xcb_shm_get_image_reply_t * img; img = xcb_shm_get_image_reply(this->xcb, this->imgC, NULL); diff --git a/host/platform/Windows/capture/DXGI/src/dxgi.c b/host/platform/Windows/capture/DXGI/src/dxgi.c index 09173200..d6f77f21 100644 --- a/host/platform/Windows/capture/DXGI/src/dxgi.c +++ b/host/platform/Windows/capture/DXGI/src/dxgi.c @@ -30,7 +30,6 @@ #include "common/runningavg.h" #include "common/KVMFR.h" -#include #include #include #include @@ -170,7 +169,7 @@ static void dxgi_initOptions(void) static bool dxgi_create(CaptureGetPointerBuffer getPointerBufferFn, CapturePostPointerBuffer postPointerBufferFn) { - assert(!this); + DEBUG_ASSERT(!this); this = calloc(sizeof(struct iface), 1); if (!this) { @@ -200,7 +199,7 @@ static bool dxgi_create(CaptureGetPointerBuffer getPointerBufferFn, CapturePostP static bool dxgi_init(void) { - assert(this); + DEBUG_ASSERT(this); this->desktop = OpenInputDesktop(0, FALSE, GENERIC_READ); if (!this->desktop) @@ -601,7 +600,7 @@ static void dxgi_stop(void) static bool dxgi_deinit(void) { - assert(this); + DEBUG_ASSERT(this); for (int i = 0; i < this->maxTextures; ++i) { @@ -677,7 +676,7 @@ static bool dxgi_deinit(void) static void dxgi_free(void) { - assert(this); + DEBUG_ASSERT(this); if (this->initialized) dxgi_deinit(); @@ -785,8 +784,8 @@ static void computeFrameDamage(Texture * tex) static CaptureResult dxgi_capture(void) { - assert(this); - assert(this->initialized); + DEBUG_ASSERT(this); + DEBUG_ASSERT(this->initialized); Texture * tex = NULL; CaptureResult result; @@ -1008,8 +1007,8 @@ static CaptureResult dxgi_capture(void) static CaptureResult dxgi_waitFrame(CaptureFrame * frame, const size_t maxFrameSize) { - assert(this); - assert(this->initialized); + DEBUG_ASSERT(this); + DEBUG_ASSERT(this->initialized); // NOTE: the event may be signaled when there are no frames available if (atomic_load_explicit(&this->texReady, memory_order_acquire) == 0) @@ -1080,8 +1079,8 @@ static CaptureResult dxgi_waitFrame(CaptureFrame * frame, const size_t maxFrameS static CaptureResult dxgi_getFrame(FrameBuffer * frame, const unsigned int height, int frameIndex) { - assert(this); - assert(this->initialized); + DEBUG_ASSERT(this); + DEBUG_ASSERT(this->initialized); Texture * tex = &this->texture[this->texRIndex]; @@ -1127,7 +1126,7 @@ static CaptureResult dxgi_getFrame(FrameBuffer * frame, static CaptureResult dxgi_releaseFrame(void) { - assert(this); + DEBUG_ASSERT(this); if (!this->needsRelease) return CAPTURE_RESULT_OK; diff --git a/host/platform/Windows/capture/NVFBC/src/nvfbc.c b/host/platform/Windows/capture/NVFBC/src/nvfbc.c index ae3dd224..9ef82b39 100644 --- a/host/platform/Windows/capture/NVFBC/src/nvfbc.c +++ b/host/platform/Windows/capture/NVFBC/src/nvfbc.c @@ -30,7 +30,6 @@ #include "common/rects.h" #include "common/thread.h" #include "common/KVMFR.h" -#include #include #include #include