Possible fix for queue overflow

This commit is contained in:
yaw-man 2022-08-11 19:10:55 -03:00
parent 64b045fa77
commit e3c74ff15d
3 changed files with 11 additions and 2 deletions

View File

@ -29,7 +29,11 @@ public:
void NewPacket() {
//Serial number of newest packet.
UINT oldest, newest;
gpWTQueuePacketsEx(hctx, &oldest, &newest);
//This function returns false when it fails.
if (!gpWTQueuePacketsEx(hctx, &oldest, &newest)) {
//Queue full, flush it all.
gpWTPacketsGet(hctx, gpWTQueueSizeGet(hctx), nullptr);
}
//Store newest packet in pkt, flush older packets.
gpWTPacket(hctx, newest, &pkt);

View File

@ -39,6 +39,7 @@ WTMGRDEFCONTEXTEX gpWTMgrDefContextEx = nullptr;
// TODO - add more wintab32 function pointers as needed
WTQPACKETSEX gpWTQueuePacketsEx = nullptr;
WTQSIZEGET gpWTQueueSizeGet = nullptr;
//////////////////////////////////////////////////////////////////////////////
// Purpose
@ -83,6 +84,7 @@ BOOL LoadWintab(void)
gpWTMgrDefContext = (WTMGRDEFCONTEXT)GetProcAddress(ghWintab, "WTMgrDefContext");
gpWTMgrDefContextEx = (WTMGRDEFCONTEXTEX)GetProcAddress(ghWintab, "WTMgrDefContextEx");
gpWTQueuePacketsEx = (WTQPACKETSEX)GetProcAddress(ghWintab, "WTQueuePacketsEx");
gpWTQueueSizeGet = (WTQSIZEGET)GetProcAddress(ghWintab, "WTQueueSizeGet");
// TODO - don't forget to NULL out pointers in UnloadWintab().
return TRUE;
@ -123,6 +125,7 @@ void UnloadWintab(void)
gpWTMgrDefContext = nullptr;
gpWTMgrDefContextEx = nullptr;
gpWTQueuePacketsEx = nullptr;
gpWTQueueSizeGet = nullptr;
}
//////////////////////////////////////////////////////////////////////////////

View File

@ -48,6 +48,7 @@ using WTMGRDEFCONTEXTEX = HCTX (API*)(HMGR, UINT, BOOL);
// TODO - add more wintab32 function defs as needed
using WTQPACKETSEX = BOOL(API*)(HCTX, UINT FAR*, UINT FAR*);
using WTQSIZEGET = int (API*)(HCTX);
//////////////////////////////////////////////////////////////////////////////
@ -77,6 +78,7 @@ extern WTMGRDEFCONTEXTEX gpWTMgrDefContextEx;
// TODO - add more wintab32 function pointers as needed
extern WTQPACKETSEX gpWTQueuePacketsEx;
extern WTQSIZEGET gpWTQueueSizeGet;
//////////////////////////////////////////////////////////////////////////////