Skip to content

Commit 49fd43c

Browse files
Modernize Oboe API usage: use non-deprecated shared_ptr callbacks, add spatialization and capture policy
- Replace deprecated setFramesPerCallback() with setFramesPerDataCallback() - Replace deprecated raw pointer setCallback() with shared_ptr setDataCallback() and setErrorCallback() (non-owning aliasing shared_ptr for error callback) - Change StabilizedCallback from unique_ptr to shared_ptr to match new API - Add setIsContentSpatialized(true) — BASS pre-mixes audio, prevent double processing - Add setAllowedCapturePolicy(AllowNone) — competitive integrity for rhythm game Agent-Logs-Url: https://github.com/winnerspiros/osu/sessions/23c3ea85-9888-4a55-b8a7-1e5e11dc2e74 Co-authored-by: winnerspiros <1675249+winnerspiros@users.noreply.github.com>
1 parent 5ec29c0 commit 49fd43c

2 files changed

Lines changed: 13 additions & 4 deletions

File tree

osu.Android/Native/oboe_bridge.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,8 @@ bool OboeBridge::open(int32_t sampleRate) {
9393
oboe::OboeExtensions::setMMapEnabled(true);
9494

9595
// Initialise StabilizedCallback to even out callback execution time.
96-
stabilizedCallback_ = std::make_unique<oboe::StabilizedCallback>(this);
96+
// shared_ptr is used to satisfy the non-deprecated setDataCallback overload.
97+
stabilizedCallback_ = std::make_shared<oboe::StabilizedCallback>(this);
9798

9899
oboe::AudioStreamBuilder builder;
99100
builder.setDirection(oboe::Direction::Output)
@@ -106,11 +107,19 @@ bool OboeBridge::open(int32_t sampleRate) {
106107
->setContentType(oboe::ContentType::Music)
107108
->setUsage(oboe::Usage::Game)
108109
->setAudioApi(oboe::AudioApi::AAudio)
109-
->setFramesPerCallback(oboe::kUnspecified)
110+
->setFramesPerDataCallback(oboe::kUnspecified)
110111
->setBufferCapacityInFrames(oboe::kUnspecified)
111112
->setChannelConversionAllowed(false)
112113
->setFormatConversionAllowed(false)
113-
->setCallback(stabilizedCallback_.get());
114+
// Audio is pre-mixed by BASS — tell Android not to spatialize it again.
115+
->setIsContentSpatialized(true)
116+
// Prevent other apps from capturing our audio stream (competitive integrity).
117+
->setAllowedCapturePolicy(oboe::AllowedCapturePolicy::AllowNone)
118+
// Use shared_ptr overload (non-deprecated) for data callback.
119+
->setDataCallback(stabilizedCallback_)
120+
// Non-owning shared_ptr for error callback — OboeBridge outlives the stream.
121+
->setErrorCallback(std::shared_ptr<oboe::AudioStreamErrorCallback>(
122+
std::shared_ptr<void>(), static_cast<oboe::AudioStreamErrorCallback*>(this)));
114123

115124
oboe::Result result = builder.openStream(stream_);
116125

osu.Android/Native/oboe_bridge.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ class OboeBridge : public oboe::AudioStreamCallback {
4444

4545
private:
4646
std::shared_ptr<oboe::AudioStream> stream_;
47+
std::shared_ptr<oboe::StabilizedCallback> stabilizedCallback_;
4748
std::unique_ptr<oboe::LatencyTuner> tuner_;
48-
std::unique_ptr<oboe::StabilizedCallback> stabilizedCallback_;
4949

5050
mutable std::mutex streamLock_;
5151
std::atomic<bool> active_{false};

0 commit comments

Comments
 (0)