Skip to content

Commit e0d4c05

Browse files
osn-replay-buffer: invoke output handler to save replays (#1689)
* osn-replay-buffer: invoke output handler to save * makes test more reliable resulting in much less replay buffer failures on the slower CI machines * follows similar pattern used by OBS - ReplayBufferSave * enable replayBuffer.save test on MacOS * Update check to use established pattern Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
1 parent e106057 commit e0d4c05

2 files changed

Lines changed: 17 additions & 19 deletions

File tree

obs-studio-server/source/osn-replay-buffer.cpp

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -152,19 +152,23 @@ void osn::IReplayBuffer::Query(void *data, const int64_t id, const std::vector<i
152152

153153
void osn::IReplayBuffer::Save(void *data, const int64_t id, const std::vector<ipc::value> &args, std::vector<ipc::value> &rval)
154154
{
155-
obs_enum_hotkeys(
156-
[](void *data, obs_hotkey_id id, obs_hotkey_t *key) {
157-
if (obs_hotkey_get_registerer_type(key) == OBS_HOTKEY_REGISTERER_OUTPUT) {
158-
std::string key_name = obs_hotkey_get_name(key);
159-
if (key_name.compare("ReplayBuffer.Save") == 0) {
160-
obs_hotkey_enable_callback_rerouting(true);
161-
obs_hotkey_trigger_routed_callback(id, true);
162-
}
163-
}
164-
return true;
165-
},
166-
nullptr);
155+
ReplayBuffer *replayBuffer = static_cast<ReplayBuffer *>(osn::IFileOutput::Manager::GetInstance().find(args[0].value_union.ui64));
156+
if (!replayBuffer) {
157+
PRETTY_ERROR_RETURN(ErrorCode::InvalidReference, "ReplayBuffer reference is not valid.");
158+
}
167159

160+
obs_output_t *output = replayBuffer->GetOutput();
161+
if (!output) {
162+
PRETTY_ERROR_RETURN(ErrorCode::InvalidReference, "Invalid replay buffer output.");
163+
}
164+
165+
calldata_t cd = {0};
166+
proc_handler_t *ph = obs_output_get_proc_handler(output);
167+
bool hasInvoked = proc_handler_call(ph, "save", &cd);
168+
calldata_free(&cd);
169+
170+
if (!hasInvoked)
171+
PRETTY_ERROR_RETURN(ErrorCode::NotFound, "Could not find ReplayBuffer::Save");
168172
rval.push_back(ipc::value((uint64_t)ErrorCode::Ok));
169173
AUTO_DEBUG;
170-
}
174+
}

tests/osn-tests/src/test_osn_advanced_replayBuffer.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,6 @@ describe(testName, () => {
131131
});
132132

133133
it('Start advanced replay buffer - Use Recording', async function() {
134-
if (obs.isDarwin()) {
135-
this.skip();
136-
}
137134
replayBuffer = osn.AdvancedReplayBufferFactory.create();
138135
replayBuffer.path = path.join(path.normalize(__dirname), '..', 'osnData');
139136
replayBuffer.format = osn.ERecordingFormat.MP4;
@@ -261,9 +258,6 @@ describe(testName, () => {
261258
});
262259

263260
it('Start advanced replay buffer - Use Stream through Recording', async function() {
264-
if (obs.isDarwin()) {
265-
this.skip();
266-
}
267261
replayBuffer = osn.AdvancedReplayBufferFactory.create();
268262
replayBuffer.path = path.join(path.normalize(__dirname), '..', 'osnData');
269263
replayBuffer.format = osn.ERecordingFormat.MP4;

0 commit comments

Comments
 (0)