[host] capture: switch all asserts to DEBUG_ASSERT

This commit is contained in:
Quantum 2021-08-13 19:30:41 -04:00 committed by Geoffrey McRae
parent a9241f6710
commit 4f7ce91e7f
3 changed files with 19 additions and 22 deletions

View File

@ -23,7 +23,6 @@
#include "common/debug.h" #include "common/debug.h"
#include "common/event.h" #include "common/event.h"
#include <string.h> #include <string.h>
#include <assert.h>
#include <stdlib.h> #include <stdlib.h>
#include <inttypes.h> #include <inttypes.h>
#include <xcb/shm.h> #include <xcb/shm.h>
@ -64,7 +63,7 @@ static const char * xcb_getName(void)
static bool xcb_create(CaptureGetPointerBuffer getPointerBufferFn, CapturePostPointerBuffer postPointerBufferFn) static bool xcb_create(CaptureGetPointerBuffer getPointerBufferFn, CapturePostPointerBuffer postPointerBufferFn)
{ {
assert(!this); DEBUG_ASSERT(!this);
this = (struct xcb *)calloc(sizeof(struct xcb), 1); this = (struct xcb *)calloc(sizeof(struct xcb), 1);
this->shmID = -1; this->shmID = -1;
this->data = (void *)-1; this->data = (void *)-1;
@ -82,8 +81,8 @@ static bool xcb_create(CaptureGetPointerBuffer getPointerBufferFn, CapturePostPo
static bool xcb_init(void) static bool xcb_init(void)
{ {
assert(this); DEBUG_ASSERT(this);
assert(!this->initialized); DEBUG_ASSERT(!this->initialized);
lgResetEvent(this->frameEvent); lgResetEvent(this->frameEvent);
@ -134,7 +133,7 @@ fail:
static bool xcb_deinit(void) static bool xcb_deinit(void)
{ {
assert(this); DEBUG_ASSERT(this);
if ((uintptr_t)this->data != -1) if ((uintptr_t)this->data != -1)
{ {
@ -167,8 +166,8 @@ static void xcb_free(void)
static CaptureResult xcb_capture(void) static CaptureResult xcb_capture(void)
{ {
assert(this); DEBUG_ASSERT(this);
assert(this->initialized); DEBUG_ASSERT(this->initialized);
if (!this->hasFrame) if (!this->hasFrame)
{ {
@ -211,8 +210,8 @@ static CaptureResult xcb_waitFrame(CaptureFrame * frame,
static CaptureResult xcb_getFrame(FrameBuffer * frame, static CaptureResult xcb_getFrame(FrameBuffer * frame,
const unsigned int height, int frameIndex) const unsigned int height, int frameIndex)
{ {
assert(this); DEBUG_ASSERT(this);
assert(this->initialized); DEBUG_ASSERT(this->initialized);
xcb_shm_get_image_reply_t * img; xcb_shm_get_image_reply_t * img;
img = xcb_shm_get_image_reply(this->xcb, this->imgC, NULL); img = xcb_shm_get_image_reply(this->xcb, this->imgC, NULL);

View File

@ -30,7 +30,6 @@
#include "common/runningavg.h" #include "common/runningavg.h"
#include "common/KVMFR.h" #include "common/KVMFR.h"
#include <assert.h>
#include <stdatomic.h> #include <stdatomic.h>
#include <unistd.h> #include <unistd.h>
#include <dxgi.h> #include <dxgi.h>
@ -170,7 +169,7 @@ static void dxgi_initOptions(void)
static bool dxgi_create(CaptureGetPointerBuffer getPointerBufferFn, CapturePostPointerBuffer postPointerBufferFn) static bool dxgi_create(CaptureGetPointerBuffer getPointerBufferFn, CapturePostPointerBuffer postPointerBufferFn)
{ {
assert(!this); DEBUG_ASSERT(!this);
this = calloc(sizeof(struct iface), 1); this = calloc(sizeof(struct iface), 1);
if (!this) if (!this)
{ {
@ -200,7 +199,7 @@ static bool dxgi_create(CaptureGetPointerBuffer getPointerBufferFn, CapturePostP
static bool dxgi_init(void) static bool dxgi_init(void)
{ {
assert(this); DEBUG_ASSERT(this);
this->desktop = OpenInputDesktop(0, FALSE, GENERIC_READ); this->desktop = OpenInputDesktop(0, FALSE, GENERIC_READ);
if (!this->desktop) if (!this->desktop)
@ -601,7 +600,7 @@ static void dxgi_stop(void)
static bool dxgi_deinit(void) static bool dxgi_deinit(void)
{ {
assert(this); DEBUG_ASSERT(this);
for (int i = 0; i < this->maxTextures; ++i) for (int i = 0; i < this->maxTextures; ++i)
{ {
@ -677,7 +676,7 @@ static bool dxgi_deinit(void)
static void dxgi_free(void) static void dxgi_free(void)
{ {
assert(this); DEBUG_ASSERT(this);
if (this->initialized) if (this->initialized)
dxgi_deinit(); dxgi_deinit();
@ -785,8 +784,8 @@ static void computeFrameDamage(Texture * tex)
static CaptureResult dxgi_capture(void) static CaptureResult dxgi_capture(void)
{ {
assert(this); DEBUG_ASSERT(this);
assert(this->initialized); DEBUG_ASSERT(this->initialized);
Texture * tex = NULL; Texture * tex = NULL;
CaptureResult result; CaptureResult result;
@ -1008,8 +1007,8 @@ static CaptureResult dxgi_capture(void)
static CaptureResult dxgi_waitFrame(CaptureFrame * frame, const size_t maxFrameSize) static CaptureResult dxgi_waitFrame(CaptureFrame * frame, const size_t maxFrameSize)
{ {
assert(this); DEBUG_ASSERT(this);
assert(this->initialized); DEBUG_ASSERT(this->initialized);
// NOTE: the event may be signaled when there are no frames available // NOTE: the event may be signaled when there are no frames available
if (atomic_load_explicit(&this->texReady, memory_order_acquire) == 0) 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, static CaptureResult dxgi_getFrame(FrameBuffer * frame,
const unsigned int height, int frameIndex) const unsigned int height, int frameIndex)
{ {
assert(this); DEBUG_ASSERT(this);
assert(this->initialized); DEBUG_ASSERT(this->initialized);
Texture * tex = &this->texture[this->texRIndex]; Texture * tex = &this->texture[this->texRIndex];
@ -1127,7 +1126,7 @@ static CaptureResult dxgi_getFrame(FrameBuffer * frame,
static CaptureResult dxgi_releaseFrame(void) static CaptureResult dxgi_releaseFrame(void)
{ {
assert(this); DEBUG_ASSERT(this);
if (!this->needsRelease) if (!this->needsRelease)
return CAPTURE_RESULT_OK; return CAPTURE_RESULT_OK;

View File

@ -30,7 +30,6 @@
#include "common/rects.h" #include "common/rects.h"
#include "common/thread.h" #include "common/thread.h"
#include "common/KVMFR.h" #include "common/KVMFR.h"
#include <assert.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdatomic.h> #include <stdatomic.h>
#include <windows.h> #include <windows.h>