Skip to content

Commit ec93f56

Browse files
committed
fix: return correct replay file path
1 parent 165e451 commit ec93f56

File tree

2 files changed

+27
-9
lines changed

2 files changed

+27
-9
lines changed

samples/ObsKit.NET.Sample.ReplayBuffer/Program.cs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,13 +104,25 @@
104104
try
105105
{
106106
replayBuffer.Save();
107-
Console.WriteLine($"[{DateTime.Now:HH:mm:ss}] Replay saved to {outputDir}");
107+
108+
// Poll every 100ms for the save to complete, then get the path
109+
string? savedPath = null;
110+
for (int i = 0; i < 10; i++)
111+
{
112+
Thread.Sleep(100);
113+
savedPath = replayBuffer.GetLastReplayPath();
114+
if (!string.IsNullOrEmpty(savedPath))
115+
break;
116+
}
117+
118+
if (!string.IsNullOrEmpty(savedPath))
119+
Console.WriteLine($"[{DateTime.Now:HH:mm:ss}] Replay saved to: {savedPath}");
120+
else
121+
Console.WriteLine($"[{DateTime.Now:HH:mm:ss}] Could not retrieve replay path");
108122
}
109123
catch (InvalidOperationException ex)
110124
{
111125
Console.WriteLine($"[{DateTime.Now:HH:mm:ss}] {ex.Message}");
112-
Console.WriteLine(" Note: Programmatic saving requires obs-frontend-api integration.");
113-
Console.WriteLine(" The buffer is still recording - use OBS hotkeys to save if configured.");
114126
}
115127
}
116128
else if (key.Key == ConsoleKey.Q)

src/ObsKit.NET/Native/Interop/ObsSignal.cs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -184,11 +184,11 @@ private static partial byte proc_handler_call_native(
184184
#region Memory (for calldata management)
185185

186186
/// <summary>
187-
/// Allocates zeroed memory using OBS's allocator.
187+
/// Allocates memory using OBS's allocator.
188188
/// </summary>
189-
[LibraryImport(Lib, EntryPoint = "bzalloc")]
189+
[LibraryImport(Lib, EntryPoint = "bmalloc")]
190190
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
191-
internal static partial nint bzalloc(nuint size);
191+
internal static partial nint bmalloc(nuint size);
192192

193193
/// <summary>
194194
/// Frees memory allocated by OBS's allocator.
@@ -211,8 +211,15 @@ private static partial byte proc_handler_call_native(
211211
/// </summary>
212212
internal static nint calldata_create()
213213
{
214-
var cd = bzalloc(CalldataSize);
215-
// bzalloc already zeros the memory, which is equivalent to calldata_init
214+
var cd = bmalloc(CalldataSize);
215+
if (cd != nint.Zero)
216+
{
217+
// Zero the memory (equivalent to bzalloc/calldata_init)
218+
unsafe
219+
{
220+
new Span<byte>((void*)cd, (int)CalldataSize).Clear();
221+
}
222+
}
216223
return cd;
217224
}
218225

@@ -228,7 +235,6 @@ internal static void calldata_destroy(nint calldata)
228235
{
229236
var stackPtr = *(nint*)calldata;
230237
// Check if not fixed (4th field, which is a bool - need to check offset)
231-
// For simplicity, we'll just free the stack pointer if it's non-zero
232238
// The 'fixed' flag is at offset: sizeof(nint) + sizeof(nuint) + sizeof(nuint)
233239
var fixedOffset = nint.Size + nint.Size + nint.Size;
234240
var isFixed = *(byte*)(calldata + fixedOffset) != 0;

0 commit comments

Comments
 (0)