Compare commits

..

8 Commits

Author SHA1 Message Date
Geoffrey McRae
188f25c6bf [host] nvfbc: increase retry timeout to 1 second 2022-12-09 08:00:03 +11:00
Geoffrey McRae
8619f787b9 [host] nvfbc: retry on failure to init
@quantum has observed nvfbc under rare circumstances fail to initialize,
this adds a retry to the init with a short delay to hopefully recover
from this situation.
2022-12-08 21:24:11 +11:00
Quantum
60ac03ebaf [client] wayland: implement window size setting for xdg-shell
This should allow win:autoResize to work on Wayland when the compositor
supports such an operation.
2022-12-08 21:08:33 +11:00
Quantum
e1ebde3cd2 [host] windows: log to stderr that logs will continue in file
This prevents users from posting the stderr as if it's the only output.
2022-12-08 21:08:07 +11:00
Quantum
f519904c38 [host] app: clarify that config file not found is not fatal
This prevents users from thinking this is the problem they are facing.
2022-12-08 21:08:07 +11:00
Geoffrey McRae
fa6f1abaac [obs] fix compatibility with updated LGMP build 2022-11-08 00:00:39 +11:00
Geoffrey McRae
875242fe15 [host] app: improve throttleFPS logic 2022-11-07 22:56:20 +11:00
Geoffrey McRae
20b5957999 [client] update LGMP to fix buffer overflow bug 2022-11-07 21:57:10 +11:00
10 changed files with 96 additions and 79 deletions

View File

@@ -68,12 +68,27 @@ static void xdgToplevelConfigure(void * data, struct xdg_toplevel * xdgToplevel,
wlWm.width = width;
wlWm.height = height;
wlWm.fullscreen = false;
wlWm.floating = true;
enum xdg_toplevel_state * state;
wl_array_for_each(state, states)
{
if (*state == XDG_TOPLEVEL_STATE_FULLSCREEN)
switch (*state)
{
case XDG_TOPLEVEL_STATE_FULLSCREEN:
wlWm.fullscreen = true;
// fallthrough
case XDG_TOPLEVEL_STATE_MAXIMIZED:
case XDG_TOPLEVEL_STATE_TILED_LEFT:
case XDG_TOPLEVEL_STATE_TILED_RIGHT:
case XDG_TOPLEVEL_STATE_TILED_TOP:
case XDG_TOPLEVEL_STATE_TILED_BOTTOM:
wlWm.floating = false;
break;
default:
break;
}
}
}
@@ -156,5 +171,14 @@ void waylandMinimize(void)
void waylandShellResize(int w, int h)
{
//TODO: Implement resize for XDG.
if (!wlWm.floating)
return;
wlWm.width = w;
wlWm.height = h;
xdg_surface_set_window_geometry(wlWm.xdgSurface, 0, 0, w, h);
wlWm.needsResize = true;
app_invalidateWindow(true);
waylandStopWaitFrame();
}

View File

@@ -112,6 +112,7 @@ struct WaylandDSState
bool fractionalScale;
bool needsResize;
bool fullscreen;
bool floating;
uint32_t resizeSerial;
bool configured;
bool warpSupport;

View File

@@ -478,9 +478,8 @@ void core_handleMouseNormal(double ex, double ey)
if (!g_state.stopVideo &&
g_state.kvmfrFeatures & KVMFR_FEATURE_SETCURSORPOS)
{
const KVMFRMessage_SetCursorPos msg = {
const KVMFRSetCursorPos msg = {
.msg.type = KVMFR_MESSAGE_SETCURSORPOS,
.msg.clientID = g_state.clientID,
.x = round(guest.x),
.y = round(guest.y)
};

View File

@@ -1434,7 +1434,7 @@ restart:
}
status = lgmpClientSessionInit(g_state.lgmp, &udataSize, (uint8_t **)&udata,
&g_state.clientID);
NULL);
switch(status)
{
case LGMP_OK:

View File

@@ -121,7 +121,6 @@ struct AppState
struct IVSHMEM shm;
PLGMPClient lgmp;
uint32_t clientID;
PLGMPClientQueue pointerQueue;
LG_Lock pointerQueueLock;
KVMFRFeatureFlags kvmfrFeatures;

View File

@@ -28,7 +28,7 @@
#include "types.h"
#define KVMFR_MAGIC "KVMFR---"
#define KVMFR_VERSION 20
#define KVMFR_VERSION 19
#define KVMFR_MAX_DAMAGE_RECTS 64
@@ -56,8 +56,7 @@ typedef uint32_t KVMFRFeatureFlags;
enum
{
KVMFR_MESSAGE_SETCURSORPOS,
KVMFR_MESSAGE_FRAME_TIME
KVMFR_MESSAGE_SETCURSORPOS
};
typedef uint32_t KVMFRMessageType;
@@ -138,8 +137,6 @@ typedef struct KVMFRFrame
{
uint32_t formatVer; // the frame format version number
uint32_t frameSerial; // the unique frame number
uint64_t frameTimeUs; // when the capture was started
uint64_t frameElapsedUs; // total time elapsed to capture the frame
FrameType type; // the frame data type
uint32_t screenWidth; // the client's screen width
uint32_t screenHeight; // the client's screen height
@@ -158,28 +155,14 @@ KVMFRFrame;
typedef struct KVMFRMessage
{
KVMFRMessageType type;
uint32_t clientID;
}
KVMFRMessage;
typedef struct KVMFRMessage_SetCursorPos
typedef struct KVMFRSetCursorPos
{
KVMFRMessage msg;
int32_t x, y;
}
KVMFRMessage_SetCursorPos;
typedef struct KVMFRMessage_FrameTime
{
KVMFRMessage msg;
/* this is the desired time to start the next capture operation where zero is
* immediate. This is only a hint to the host application and may not be
* honored. The value provided should be offset from the latest frame's
* frameTimeUs. When multiple clients are sending this message, the one with
* the lowest value will be used.
*/
uint64_t frameTimeUs;
}
KVMFRMessage_FrameTime;
KVMFRSetCursorPos;
#endif

View File

@@ -316,6 +316,10 @@ static bool nvfbc_init(void)
}
int adapterIndex = option_get_int("nvfbc", "adapterIndex");
bool created = false;
for(int retry = 0; retry < 2; ++retry)
{
// NOTE: Calling this on hardware that doesn't support NvFBC such as GeForce
// causes a substantial performance pentalty even if it fails! As such we only
// attempt NvFBC as a last resort, or if configured via the app:capture
@@ -335,19 +339,27 @@ static bool nvfbc_init(void)
&this->maxWidth, &this->maxHeight))
{
adapterIndex = i;
created = true;
break;
}
}
IDirect3D9_Release(d3d);
if (adapterIndex < 0)
{
free(privData);
return false;
}
}
else
{
if (!NvFBCToSysCreate(adapterIndex, privData, privDataLen, &this->nvfbc, &this->maxWidth, &this->maxHeight))
continue;
created = true;
}
if (created)
break;
//1000ms delay before retry
nsleep(1000000000);
}
if (!created)
{
free(privData);
return false;

View File

@@ -526,7 +526,13 @@ bool app_init(void)
// redirect stderr to a file
if (logFile && strcmp(logFile, "stderr") != 0)
freopen(logFile, "a", stderr);
{
DEBUG_INFO("Logs will be written to: %s", logFile);
DEBUG_INFO("Please see there for any further information");
if (!freopen(logFile, "a", stderr))
DEBUG_WARN("Failed to open log file, will log to stderr");
}
// always flush stderr
setbuf(stderr, NULL);

View File

@@ -96,7 +96,6 @@ struct app
unsigned int frameIndex;
bool frameValid;
uint32_t frameSerial;
uint64_t frameTimeUs;
CaptureInterface * iface;
@@ -269,7 +268,6 @@ static bool sendFrame(void)
}
fi->formatVer = frame.formatVer;
fi->frameTimeUs = app.frameTimeUs;
fi->frameSerial = app.frameSerial++;
fi->screenWidth = frame.screenWidth;
fi->screenHeight = frame.screenHeight;
@@ -297,11 +295,6 @@ static bool sendFrame(void)
FrameBuffer * fb = (FrameBuffer *)(((uint8_t*)fi) + fi->offset);
framebuffer_prepare(fb);
// calculate the elapsed time as late as possible, note that this does not
// take into account the memory copy time and the client's that care about
// this value will need to take this into account
fi->frameElapsedUs = microtime() - app.frameTimeUs;
/* we post and then get the frame, this is intentional! */
if ((status = lgmpHostQueuePost(app.frameQueue, 0,
app.frameMemory[app.frameIndex])) != LGMP_OK)
@@ -755,7 +748,7 @@ int app_main(int argc, char * argv[])
if (option_load(configFile))
DEBUG_INFO("Configuration file loaded");
else
DEBUG_INFO("Configuration file not found or invalid");
DEBUG_INFO("Configuration file not found or invalid, continuing anyway...");
// parse the command line arguments
if (!option_parse(argc, argv))
@@ -908,20 +901,20 @@ int app_main(int argc, char * argv[])
LG_UNLOCK(app.pointerLock);
}
const uint64_t now = microtime();
const uint64_t delta = now - previousFrameTime;
const uint64_t delta = microtime() - previousFrameTime;
if (delta < throttleUs)
{
nsleep((throttleUs - delta) * 1000);
previousFrameTime = microtime();
const uint64_t us = throttleUs - delta;
// only delay if the time is reasonable
if (us > 1000)
nsleep(us * 1000);
}
else
previousFrameTime = now;
app.frameTimeUs = microtime();
const uint64_t captureStart = microtime();
switch(iface->capture())
{
case CAPTURE_RESULT_OK:
previousFrameTime = captureStart;
break;
case CAPTURE_RESULT_TIMEOUT:

View File

@@ -421,7 +421,7 @@ static void lgUpdate(void * data, obs_data_t * settings)
usleep(200000);
if (lgmpClientSessionInit(this->lgmp, &udataSize, (uint8_t **)&udata)
if (lgmpClientSessionInit(this->lgmp, &udataSize, (uint8_t **)&udata, NULL)
!= LGMP_OK)
return;