Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions osu.Android/AndroidNativeBridgeManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ public void StopOboeBridge()
}

[MethodImpl(MethodImplOptions.NoInlining)]
public static bool SetThreadAffinity(int coreMask) => OboeAudioBridge.nSetThreadAffinity(coreMask) != 0;
public double GetMeasuredAudioLatencyMs()
{
return (oboeBridge as OboeAudioBridge)?.GetOutputLatencyMs() ?? -1;
Expand Down Expand Up @@ -115,6 +116,7 @@ public void StartVulkanProbe()
}

[MethodImpl(MethodImplOptions.NoInlining)]
public bool IsVulkanRecommended() => (vulkanProbe as VulkanProbe)?.IsRecommended ?? false;
public void StopVulkanProbe()
{
(vulkanProbe as VulkanProbe)?.Dispose();
Expand Down
5 changes: 5 additions & 0 deletions osu.Android/Native/OboeAudioBridge.cs
Original file line number Diff line number Diff line change
Expand Up @@ -337,5 +337,10 @@

[DllImport(lib_name)]
private static extern void nOboeSetProvider(IntPtr ptr, IntPtr provider);
[DllImport(lib_name)] public static extern byte nSetThreadAffinity(int coreMask);

Check warning on line 340 in osu.Android/Native/OboeAudioBridge.cs

View workflow job for this annotation

GitHub Actions / Build only (Android)

P/Invoke method 'nSetThreadAffinity' should not be visible (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1401)

Check warning on line 340 in osu.Android/Native/OboeAudioBridge.cs

View workflow job for this annotation

GitHub Actions / Build only (Android)

P/Invoke method 'nSetThreadAffinity' should not be visible (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1401)

Check warning on line 340 in osu.Android/Native/OboeAudioBridge.cs

View workflow job for this annotation

GitHub Actions / Build only (Android)

P/Invoke method 'nSetThreadAffinity' should not be visible (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1401)

Check warning on line 340 in osu.Android/Native/OboeAudioBridge.cs

View workflow job for this annotation

GitHub Actions / Build only (Android)

P/Invoke method 'nSetThreadAffinity' should not be visible (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1401)
[DllImport(lib_name)] public static extern IntPtr nADPFCreateSession(long targetDurationNanos);

Check warning on line 341 in osu.Android/Native/OboeAudioBridge.cs

View workflow job for this annotation

GitHub Actions / Build only (Android)

P/Invoke method 'nADPFCreateSession' should not be visible (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1401)

Check warning on line 341 in osu.Android/Native/OboeAudioBridge.cs

View workflow job for this annotation

GitHub Actions / Build only (Android)

P/Invoke method 'nADPFCreateSession' should not be visible (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1401)

Check warning on line 341 in osu.Android/Native/OboeAudioBridge.cs

View workflow job for this annotation

GitHub Actions / Build only (Android)

P/Invoke method 'nADPFCreateSession' should not be visible (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1401)

Check warning on line 341 in osu.Android/Native/OboeAudioBridge.cs

View workflow job for this annotation

GitHub Actions / Build only (Android)

P/Invoke method 'nADPFCreateSession' should not be visible (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1401)
[DllImport(lib_name)] public static extern void nADPFReportActualDuration(IntPtr sessionPtr, long actualDurationNanos);

Check warning on line 342 in osu.Android/Native/OboeAudioBridge.cs

View workflow job for this annotation

GitHub Actions / Build only (Android)

P/Invoke method 'nADPFReportActualDuration' should not be visible (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1401)

Check warning on line 342 in osu.Android/Native/OboeAudioBridge.cs

View workflow job for this annotation

GitHub Actions / Build only (Android)

P/Invoke method 'nADPFReportActualDuration' should not be visible (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1401)
[DllImport(lib_name)] public static extern void nADPFUpdateTargetDuration(IntPtr sessionPtr, long targetDurationNanos);

Check warning on line 343 in osu.Android/Native/OboeAudioBridge.cs

View workflow job for this annotation

GitHub Actions / Build only (Android)

P/Invoke method 'nADPFUpdateTargetDuration' should not be visible (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1401)

Check warning on line 343 in osu.Android/Native/OboeAudioBridge.cs

View workflow job for this annotation

GitHub Actions / Build only (Android)

P/Invoke method 'nADPFUpdateTargetDuration' should not be visible (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1401)
[DllImport(lib_name)] public static extern void nADPFCloseSession(IntPtr sessionPtr);

Check warning on line 344 in osu.Android/Native/OboeAudioBridge.cs

View workflow job for this annotation

GitHub Actions / Build only (Android)

P/Invoke method 'nADPFCloseSession' should not be visible (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1401)

Check warning on line 344 in osu.Android/Native/OboeAudioBridge.cs

View workflow job for this annotation

GitHub Actions / Build only (Android)

P/Invoke method 'nADPFCloseSession' should not be visible (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1401)

Check warning on line 344 in osu.Android/Native/OboeAudioBridge.cs

View workflow job for this annotation

GitHub Actions / Build only (Android)

P/Invoke method 'nADPFCloseSession' should not be visible (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1401)
}
}
2 changes: 2 additions & 0 deletions osu.Android/Native/VulkanProbe.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ static VulkanProbe()
public bool SupportsGlobalPriority => !disposed && nativePtr != IntPtr.Zero && nVulkanSupportsGlobalPriority(nativePtr) != 0;
public bool SupportsMemoryBudget => !disposed && nativePtr != IntPtr.Zero && nVulkanSupportsMemoryBudget(nativePtr) != 0;

public bool IsRecommended => IsAvailable && MeetsVulkan13 && SupportsDynamicRendering && SupportsSynchronization2;

public void Dispose()
{
if (disposed) return;
Expand Down
51 changes: 50 additions & 1 deletion osu.Android/Native/oboe_bridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// See the LICENCE file in the repository root for full licence text.

#include "oboe_bridge.h"
#include "vulkan_bridge.h"
#include <oboe/OboeExtensions.h>
#include <oboe/AudioClock.h>
#include <sched.h>
Expand Down Expand Up @@ -368,3 +367,53 @@ OSU_EXPORT void nOboeSetProvider(intptr_t ptr, OboeAudioProvider provider) {
}

} // extern "C"

extern "C" {
OSU_EXPORT void nLog(int level, const char* tag, const char* msg) {
__android_log_print(level, tag, "%s", msg);
}
}

extern "C" {
OSU_EXPORT byte nSetThreadAffinity(int coreMask) {
cpu_set_t cpuset;
CPU_ZERO(&cpuset);
for (int i = 0; i < 32; i++) {
if ((coreMask >> i) & 1) {
CPU_SET(i, &cpuset);
}
}
return (sched_setaffinity(0, sizeof(cpu_set_t), &cpuset) == 0) ? 1 : 0;
}
}

#include <android/performance_hint.h>

extern "C" {
OSU_EXPORT intptr_t nADPFCreateSession(int64_t targetDurationNanos) {
auto manager = APerformanceHint_getManager();
if (!manager) return 0;

// We use the current thread as the initial thread for the session.
int32_t thread_id = gettid();
return reinterpret_cast<intptr_t>(APerformanceHint_createSession(manager, &thread_id, 1, targetDurationNanos));
}

OSU_EXPORT void nADPFReportActualDuration(intptr_t sessionPtr, int64_t actualDurationNanos) {
if (sessionPtr) {
APerformanceHint_reportActualWorkDuration(reinterpret_cast<APerformanceHintSession*>(sessionPtr), actualDurationNanos);
}
}

OSU_EXPORT void nADPFUpdateTargetDuration(intptr_t sessionPtr, int64_t targetDurationNanos) {
if (sessionPtr) {
APerformanceHint_updateTargetWorkDuration(reinterpret_cast<APerformanceHintSession*>(sessionPtr), targetDurationNanos);
}
}

OSU_EXPORT void nADPFCloseSession(intptr_t sessionPtr) {
if (sessionPtr) {
APerformanceHint_closeSession(reinterpret_cast<APerformanceHintSession*>(sessionPtr));
}
}
}
Loading
Loading