Skip to content

Commit 2607762

Browse files
Copilotwinnerspiros
andcommitted
Changes before error encountered
Co-authored-by: winnerspiros <1675249+winnerspiros@users.noreply.github.com> Agent-Logs-Url: https://github.com/winnerspiros/osu/sessions/44e3613f-a823-43ff-87a1-b2becbebcf08
1 parent 48c1297 commit 2607762

11 files changed

Lines changed: 640 additions & 25 deletions

File tree

osu.Android/Native/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ project(osu_native LANGUAGES CXX)
33

44
set(CMAKE_CXX_STANDARD 17)
55

6+
# Release build optimizations for low-latency performance.
7+
set(CMAKE_CXX_FLAGS_RELEASE "-O2 -flto -DNDEBUG")
8+
set(CMAKE_C_FLAGS_RELEASE "-O2 -flto -DNDEBUG")
9+
610
find_package(oboe REQUIRED CONFIG)
711
find_library(vulkan-lib vulkan)
812
find_library(log-lib log)

osu.Android/Native/OboeAudioBridge.cs

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ namespace osu.Android.Native
1010
/// <summary>
1111
/// Managed wrapper around the native Oboe low-latency audio bridge.
1212
/// Provides accurate audio output latency measurement for rhythm-game synchronisation.
13+
/// Optimised for lowest possible latency: AAudio preferred, exclusive mode, 1× burst buffer.
1314
/// </summary>
1415
public sealed class OboeAudioBridge : IDisposable
1516
{
@@ -125,6 +126,89 @@ public bool IsActive
125126
}
126127
}
127128

129+
/// <summary>
130+
/// The negotiated sample rate of the stream (e.g. 48000).
131+
/// </summary>
132+
public int SampleRate
133+
{
134+
get
135+
{
136+
if (disposed || nativePtr == 0) return 0;
137+
138+
try
139+
{
140+
return nOboeGetSampleRate(nativePtr);
141+
}
142+
catch
143+
{
144+
return 0;
145+
}
146+
}
147+
}
148+
149+
/// <summary>
150+
/// The burst size in frames — the optimal callback quantum.
151+
/// Lower burst = lower latency. Typical Android values: 96–192 frames.
152+
/// </summary>
153+
public int FramesPerBurst
154+
{
155+
get
156+
{
157+
if (disposed || nativePtr == 0) return 0;
158+
159+
try
160+
{
161+
return nOboeGetFramesPerBurst(nativePtr);
162+
}
163+
catch
164+
{
165+
return 0;
166+
}
167+
}
168+
}
169+
170+
/// <summary>
171+
/// The actual buffer size in frames. When optimised, this equals <see cref="FramesPerBurst"/>
172+
/// for minimum latency (1× burst).
173+
/// </summary>
174+
public int BufferSizeInFrames
175+
{
176+
get
177+
{
178+
if (disposed || nativePtr == 0) return 0;
179+
180+
try
181+
{
182+
return nOboeGetBufferSizeInFrames(nativePtr);
183+
}
184+
catch
185+
{
186+
return 0;
187+
}
188+
}
189+
}
190+
191+
/// <summary>
192+
/// Whether the stream is using AAudio (true) or OpenSL ES (false).
193+
/// AAudio provides the lowest latency path on Android 8.1+.
194+
/// </summary>
195+
public bool IsAAudio
196+
{
197+
get
198+
{
199+
if (disposed || nativePtr == 0) return false;
200+
201+
try
202+
{
203+
return nOboeIsAAudio(nativePtr) != 0;
204+
}
205+
catch
206+
{
207+
return false;
208+
}
209+
}
210+
}
211+
128212
public void Dispose()
129213
{
130214
if (disposed) return;
@@ -170,5 +254,17 @@ public void Dispose()
170254

171255
[DllImport("osu_native")]
172256
private static extern byte nOboeIsActive(long ptr);
257+
258+
[DllImport("osu_native")]
259+
private static extern int nOboeGetSampleRate(long ptr);
260+
261+
[DllImport("osu_native")]
262+
private static extern int nOboeGetFramesPerBurst(long ptr);
263+
264+
[DllImport("osu_native")]
265+
private static extern int nOboeGetBufferSizeInFrames(long ptr);
266+
267+
[DllImport("osu_native")]
268+
private static extern byte nOboeIsAAudio(long ptr);
173269
}
174270
}

osu.Android/Native/VulkanProbe.cs

Lines changed: 96 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ namespace osu.Android.Native
99
{
1010
/// <summary>
1111
/// Probes Vulkan GPU capability on the current Android device.
12-
/// Used to report hardware information and determine optimal rendering strategy.
12+
/// Used to report hardware information and determine optimal rendering strategy
13+
/// for low-latency gameplay.
1314
/// </summary>
1415
public sealed class VulkanProbe : IDisposable
1516
{
@@ -110,6 +111,88 @@ public bool SupportsSwapchain
110111
}
111112
}
112113

114+
/// <summary>
115+
/// Total device-local GPU memory in megabytes.
116+
/// </summary>
117+
public int DeviceLocalMemoryMB
118+
{
119+
get
120+
{
121+
if (disposed || nativePtr == 0) return 0;
122+
123+
try
124+
{
125+
return nVulkanGetDeviceLocalMemoryMB(nativePtr);
126+
}
127+
catch
128+
{
129+
return 0;
130+
}
131+
}
132+
}
133+
134+
/// <summary>
135+
/// Number of queue families available on the device.
136+
/// </summary>
137+
public int QueueFamilyCount
138+
{
139+
get
140+
{
141+
if (disposed || nativePtr == 0) return 0;
142+
143+
try
144+
{
145+
return nVulkanGetQueueFamilyCount(nativePtr);
146+
}
147+
catch
148+
{
149+
return 0;
150+
}
151+
}
152+
}
153+
154+
/// <summary>
155+
/// Whether the device has a dedicated compute queue (separate from graphics).
156+
/// Enables async compute for better frame pacing.
157+
/// </summary>
158+
public bool HasDedicatedComputeQueue
159+
{
160+
get
161+
{
162+
if (disposed || nativePtr == 0) return false;
163+
164+
try
165+
{
166+
return nVulkanHasDedicatedComputeQueue(nativePtr) != 0;
167+
}
168+
catch
169+
{
170+
return false;
171+
}
172+
}
173+
}
174+
175+
/// <summary>
176+
/// Whether the device has a dedicated transfer queue.
177+
/// Enables async upload for reduced frame stalls.
178+
/// </summary>
179+
public bool HasDedicatedTransferQueue
180+
{
181+
get
182+
{
183+
if (disposed || nativePtr == 0) return false;
184+
185+
try
186+
{
187+
return nVulkanHasDedicatedTransferQueue(nativePtr) != 0;
188+
}
189+
catch
190+
{
191+
return false;
192+
}
193+
}
194+
}
195+
113196
public void Dispose()
114197
{
115198
if (disposed) return;
@@ -152,5 +235,17 @@ public void Dispose()
152235

153236
[DllImport("osu_native")]
154237
private static extern byte nVulkanSupportsSwapchain(long ptr);
238+
239+
[DllImport("osu_native")]
240+
private static extern int nVulkanGetDeviceLocalMemoryMB(long ptr);
241+
242+
[DllImport("osu_native")]
243+
private static extern int nVulkanGetQueueFamilyCount(long ptr);
244+
245+
[DllImport("osu_native")]
246+
private static extern byte nVulkanHasDedicatedComputeQueue(long ptr);
247+
248+
[DllImport("osu_native")]
249+
private static extern byte nVulkanHasDedicatedTransferQueue(long ptr);
155250
}
156251
}

0 commit comments

Comments
 (0)