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
3 changes: 2 additions & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ Do not attempt to include internal Oboe headers for CPU affinity.
Instead, use standard Linux `sched_setaffinity` in `oboe_bridge.cpp` to pin the audio callback thread to high-performance cores (typically the higher-indexed half of available cores in Android big.LITTLE architectures).

## ADPF Integration
The bridge uses `stream_->reportActualWorkDuration()` within the audio callback. This is critical for the Android Dynamic Performance Framework (ADPF) to adjust CPU frequencies accurately for low-latency audio without underruns.
Oboe handles ADPF (Android Dynamic Performance Framework) automatically when `setPerformanceHintEnabled(true)` is called during stream initialization.
Manual work duration reporting (`reportActualWorkDuration`) has been removed from the public Oboe API and should not be implemented in the bridge to avoid build errors and redundant reporting.

## Build Configuration
`OBOE_ENABLE_FLOWGRAPH` is set to `OFF` in `CMakeLists.txt` to minimize binary size, as we perform all mixing in BASS and only use Oboe for final hardware delivery.
15 changes: 5 additions & 10 deletions osu.Android/Native/oboe_bridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// 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 @@ -170,8 +171,6 @@ void OboeBridge::setProvider(OboeAudioProvider provider) {
oboe::DataCallbackResult OboeBridge::onAudioReady(
oboe::AudioStream* stream, void* audioData, int32_t numFrames) {

// Record the start time of this callback for ADPF work duration reporting.
int64_t startTime = oboe::AudioClock::getNanoseconds();

OboeAudioProvider provider = provider_.load(std::memory_order_acquire);

Expand All @@ -190,10 +189,6 @@ oboe::DataCallbackResult OboeBridge::onAudioReady(
memset(audioData, 0, byteCount);
}

// Reporting actual work duration helps ADPF (Android Dynamic Performance Framework)
// adjust CPU frequency precisely to handle the audio load without skipping.
int64_t endTime = oboe::AudioClock::getNanoseconds();
if (stream->isPerformanceHintEnabled()) { stream->reportActualWorkDuration(endTime - startTime); }

uint32_t count = callbackCount_.fetch_add(1, std::memory_order_relaxed);

Expand Down Expand Up @@ -313,7 +308,7 @@ OSU_EXPORT void nOboeDestroy(intptr_t ptr) {
if (ptr) delete reinterpret_cast<OboeBridge*>(ptr);
}

OSU_EXPORT unsigned char nOboeStart(intptr_t ptr) {
OSU_EXPORT byte nOboeStart(intptr_t ptr) {
auto* bridge = reinterpret_cast<OboeBridge*>(ptr);
return (bridge && bridge->start()) ? 1 : 0;
}
Expand All @@ -328,7 +323,7 @@ OSU_EXPORT double nOboeGetLatencyMs(intptr_t ptr) {
return bridge ? bridge->getOutputLatencyMs() : -1.0;
}

OSU_EXPORT unsigned char nOboeIsActive(intptr_t ptr) {
OSU_EXPORT byte nOboeIsActive(intptr_t ptr) {
auto* bridge = reinterpret_cast<OboeBridge*>(ptr);
return (bridge && bridge->isActive()) ? 1 : 0;
}
Expand All @@ -348,12 +343,12 @@ OSU_EXPORT int nOboeGetBufferSizeInFrames(intptr_t ptr) {
return bridge ? bridge->getBufferSizeInFrames() : 0;
}

OSU_EXPORT unsigned char nOboeIsAAudio(intptr_t ptr) {
OSU_EXPORT byte nOboeIsAAudio(intptr_t ptr) {
auto* bridge = reinterpret_cast<OboeBridge*>(ptr);
return (bridge && bridge->isAAudio()) ? 1 : 0;
}

OSU_EXPORT unsigned char nOboeIsMMap(intptr_t ptr) {
OSU_EXPORT byte nOboeIsMMap(intptr_t ptr) {
auto* bridge = reinterpret_cast<OboeBridge*>(ptr);
return (bridge && bridge->isMMap()) ? 1 : 0;
}
Expand Down
4 changes: 3 additions & 1 deletion osu.Android/Native/vulkan_bridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
#pragma once

#include <vulkan/vulkan.h>
#include <string>
#include <cstdint>
#include <string>

typedef uint8_t byte;

/// Lightweight Vulkan capability probe for Android.
/// Requires Vulkan 1.3 as minimum for full feature detection (dynamic rendering,
Expand Down
Loading