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
7 changes: 7 additions & 0 deletions apps/OboeTester/app/src/main/cpp/NativeAudioContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,13 @@ class ActivityContext {
oboeCallbackProxy->setNotifyWorkloadIncreaseEnabled(enabled);
}

void setReportActualDurationDisabled(bool disabled) {
std::shared_ptr<oboe::AudioStream> stream = getOutputStream();
if (stream) {
stream->setReportActualDurationDisabled(disabled);
}
}

int32_t setBufferSizeInFrames(int streamIndex, int threshold);

virtual void setupMemoryBuffer([[maybe_unused]] std::unique_ptr<uint8_t[]>& buffer,
Expand Down
13 changes: 12 additions & 1 deletion apps/OboeTester/app/src/main/cpp/cpu/AudioWorkloadTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ class AudioWorkloadTest : oboe::AudioStreamDataCallback {
return static_cast<int32_t>(result);
}

// Apply the current setting for reporting actual duration once the stream exists.
mStream->setReportActualDurationDisabled(mReportActualDurationDisabled);

mFramesPerBurst = mStream->getFramesPerBurst();
mSampleRate = mStream->getSampleRate();
mPreviousXRunCount = 0;
Expand Down Expand Up @@ -149,7 +152,8 @@ class AudioWorkloadTest : oboe::AudioStreamDataCallback {
*/
int32_t start(int32_t targetDurationMillis, int32_t numBursts, int32_t numVoices,
int32_t alternateNumVoices, int32_t alternatingPeriodMs, bool adpfEnabled,
bool adpfWorkloadIncreaseEnabled, bool hearWorkload) {
bool adpfWorkloadIncreaseEnabled, bool hearWorkload, bool highPerformanceAudio,
bool reportActualDurationDisabled) {
std::lock_guard<std::mutex> lock(mStreamLock);
if (!mStream) {
LOGE("Error: Stream not open.");
Expand All @@ -175,7 +179,13 @@ class AudioWorkloadTest : oboe::AudioStreamDataCallback {
mRunning = true;
mHearWorkload = hearWorkload;
mAdpfWorkloadIncreaseEnabled = adpfWorkloadIncreaseEnabled;
mReportActualDurationDisabled = reportActualDurationDisabled;
mStream->setPerformanceHintEnabled(adpfEnabled);
mStream->setReportActualDurationDisabled(mReportActualDurationDisabled);
// Apply performance hint configuration if requested via runner flags.
oboe::PerformanceHintConfig cfg;
cfg.highPerformanceAudio = highPerformanceAudio;
mStream->setPerformanceHintConfig(cfg);
mStream->setBufferSizeInFrames(mNumBursts * mFramesPerBurst);
mBufferSizeInFrames = mStream->getBufferSizeInFrames();
oboe::Result result = mStream->start();
Expand Down Expand Up @@ -422,6 +432,7 @@ class AudioWorkloadTest : oboe::AudioStreamDataCallback {
std::atomic<int64_t> mStartTimeMs{0};
std::atomic<bool> mHearWorkload{false};
std::atomic<bool> mAdpfWorkloadIncreaseEnabled{false};
std::atomic<bool> mReportActualDurationDisabled{false};

// Lock to protect mCallbackStatistics
std::mutex mStatisticsLock;
Expand Down
24 changes: 14 additions & 10 deletions apps/OboeTester/app/src/main/cpp/cpu/AudioWorkloadTestRunner.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ class AudioWorkloadTestRunner {
int32_t alternatingPeriodMs,
bool adpfEnabled,
bool adpfWorkloadIncreaseEnabled,
bool hearWorkload) {
bool hearWorkload,
bool highPerformanceAudio,
bool reportActualDurationDisabled) {
if (mIsRunning) {
LOGE("Error: Test already running.");
return -1;
Expand All @@ -90,15 +92,17 @@ class AudioWorkloadTestRunner {
mIsDone = false;
mResult = 0;

int32_t result = mAudioWorkloadTest.start(
targetDurationMs,
numBursts,
numVoices,
alternateNumVoices,
alternatingPeriodMs,
adpfEnabled,
adpfWorkloadIncreaseEnabled,
hearWorkload);
int32_t result = mAudioWorkloadTest.start(
targetDurationMs,
numBursts,
numVoices,
alternateNumVoices,
alternatingPeriodMs,
adpfEnabled,
adpfWorkloadIncreaseEnabled,
hearWorkload,
highPerformanceAudio,
reportActualDurationDisabled);

if (result != static_cast<int32_t>(oboe::Result::OK)) {
mResult = -1;
Expand Down
39 changes: 34 additions & 5 deletions apps/OboeTester/app/src/main/cpp/jni-bridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,11 @@ Java_com_mobileer_oboetester_NativeEngine_getCpuCount(JNIEnv *env, jclass type)
return sysconf(_SC_NPROCESSORS_CONF);
}

JNIEXPORT jboolean JNICALL
Java_com_mobileer_oboetester_NativeEngine_isHighPerformanceAudioSupported(JNIEnv *env, jclass type) {
return oboe::AdpfWrapper::isHighPerformanceAudioSupported();
}

JNIEXPORT void JNICALL
Java_com_mobileer_oboetester_NativeEngine_setCpuAffinityMask(JNIEnv *env,
jclass type,
Expand Down Expand Up @@ -320,6 +325,13 @@ Java_com_mobileer_oboetester_TestAudioActivity_setUseAlternativeAdpf(JNIEnv *env
oboe::AdpfWrapper::setUseAlternative(enabled);
}

JNIEXPORT void JNICALL
Java_com_mobileer_oboetester_NativeEngine_setReportActualDurationDisabled(JNIEnv *env,
jclass type,
jboolean disabled) {
engine.getCurrentActivity()->setReportActualDurationDisabled(disabled);
}

JNIEXPORT jint JNICALL
Java_com_mobileer_oboetester_OboeAudioStream_setBufferSizeInFrames(
JNIEnv *env, jobject, jint streamIndex, jint threshold) {
Expand Down Expand Up @@ -352,6 +364,17 @@ Java_com_mobileer_oboetester_OboeAudioStream_setPerformanceHintEnabled(
}
}

JNIEXPORT void JNICALL
Java_com_mobileer_oboetester_OboeAudioStream_setPerformanceHintConfig(
JNIEnv *env, jobject, jint streamIndex, jboolean highPerformance) {
std::shared_ptr<oboe::AudioStream> oboeStream = engine.getCurrentActivity()->getStream(streamIndex);
if (oboeStream != nullptr) {
oboe::PerformanceHintConfig cfg;
cfg.highPerformanceAudio = highPerformance;
oboeStream->setPerformanceHintConfig(cfg);
}
}

JNIEXPORT jint JNICALL
Java_com_mobileer_oboetester_OboeAudioStream_getBufferCapacityInFrames(
JNIEnv *env, jobject, jint streamIndex) {
Expand Down Expand Up @@ -1206,10 +1229,12 @@ JNIEXPORT jint JNICALL
Java_com_mobileer_oboetester_AudioWorkloadTestActivity_start(JNIEnv *env, jobject thiz,
jint targetDurationMs, jint numBursts, jint numVoices, jint numAlternateVoices,
jint alternatingPeriodMs, jboolean adpfEnabled, jboolean adpfWorkloadIncreaseEnabled,
jboolean hearWorkload) {
jboolean hearWorkload, jboolean highPerformanceAudio,
jboolean reportActualDurationDisabled) {
return sAudioWorkload.start(targetDurationMs, numBursts, numVoices,
numAlternateVoices, alternatingPeriodMs, adpfEnabled,
adpfWorkloadIncreaseEnabled, hearWorkload);
adpfWorkloadIncreaseEnabled, hearWorkload, highPerformanceAudio,
reportActualDurationDisabled);
}

JNIEXPORT jint JNICALL
Expand Down Expand Up @@ -1437,10 +1462,14 @@ Java_com_mobileer_oboetester_AudioWorkloadTestRunnerActivity_start(JNIEnv *env,
jint alternatingPeriodMillis,
jboolean adpfEnabled,
jboolean adpfWorkloadIncreaseEnabled,
jboolean hearWorkload) {
return sAudioWorkloadRunner.start(targetDurationMs, numBursts, numVoices,
jboolean hearWorkload,
jboolean highPerformanceAudio,
jboolean reportActualDurationDisabled) {
int32_t result = sAudioWorkloadRunner.start(targetDurationMs, numBursts, numVoices,
alternateNumVoices, alternatingPeriodMillis, adpfEnabled,
adpfWorkloadIncreaseEnabled, hearWorkload);
adpfWorkloadIncreaseEnabled, hearWorkload, highPerformanceAudio,
reportActualDurationDisabled);
return result;
}

JNIEXPORT jboolean JNICALL
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,12 @@ public void setPerformanceHintEnabled(boolean checked) {
}
public void setHearWorkload(boolean checked) {
}
/**
* Configure performance hint options for this stream. Default implementation is no-op.
* @param highPerformance true to request high performance audio mode when creating the session.
*/
public void setPerformanceHintConfig(boolean highPerformance) {
}
public int notifyWorkloadIncrease(boolean cpu, boolean gpu) {
return -1;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ public class AudioWorkloadTestActivity extends BaseOboeTesterActivity {
private CheckBox mEnableAdpfBox;
private CheckBox mEnableAdpfWorkloadIncreaseBox;
private CheckBox mHearWorkloadBox;
private CheckBox mHighPerformanceAudioBox;
private CheckBox mDisableAdpfDurationBox;

private int mCpuCount;
private LinearLayout mAffinityLayout;
Expand Down Expand Up @@ -149,6 +151,9 @@ protected void onCreate(Bundle savedInstanceState) {
mEnableAdpfBox = (CheckBox) findViewById(R.id.enable_adpf);
mEnableAdpfWorkloadIncreaseBox = (CheckBox) findViewById(R.id.enable_adpf_workload_increase);
mHearWorkloadBox = (CheckBox) findViewById(R.id.hear_workload);
mHighPerformanceAudioBox = (CheckBox) findViewById(R.id.high_performance_audio);

mDisableAdpfDurationBox = (CheckBox) findViewById(R.id.disable_adpf_duration);

mOpenButton = (Button) findViewById(R.id.button_open);
mStartButton = (Button) findViewById(R.id.button_start);
Expand Down Expand Up @@ -221,10 +226,13 @@ public void openAudio(View view) {
}

public void startTest(View view) {
boolean reportActualDurationDisabled = mDisableAdpfDurationBox.isChecked();

int result = start(mTargetDurationMsSlider.getValue(), mNumBurstsSlider.getValue(),
mNumVoicesSlider.getValue(), mAlternateNumVoicesSlider.getValue(),
mAlternatingPeriodMsSlider.getValue(), mEnableAdpfBox.isChecked(),
mEnableAdpfWorkloadIncreaseBox.isChecked(), mHearWorkloadBox.isChecked());
mNumVoicesSlider.getValue(), mAlternateNumVoicesSlider.getValue(),
mAlternatingPeriodMsSlider.getValue(), mEnableAdpfBox.isChecked(),
mEnableAdpfWorkloadIncreaseBox.isChecked(), mHearWorkloadBox.isChecked(),
mHighPerformanceAudioBox.isChecked(), reportActualDurationDisabled);
if (result != OPERATION_SUCCESS) {
showErrorToast("start failed! Error:" + result);
return;
Expand Down Expand Up @@ -318,6 +326,8 @@ public void enableParamsUI(boolean enabled) {
mEnableAdpfBox.setEnabled(enabled);
mEnableAdpfWorkloadIncreaseBox.setEnabled(enabled);
mHearWorkloadBox.setEnabled(enabled);
mHighPerformanceAudioBox.setEnabled(enabled);
mDisableAdpfDurationBox.setEnabled(enabled);
}

public void updateStreamInfoView() {
Expand All @@ -331,7 +341,8 @@ public void updateStreamInfoView() {
private native int getBufferSizeInFrames();
private native int start(int targetDurationMs, int numBursts, int numVoices,
int numAlternateVoices, int alternatingPeriodMs, boolean adpfEnabled,
boolean adpfWorkloadIncreaseEnabled, boolean hearWorkload);
boolean adpfWorkloadIncreaseEnabled, boolean hearWorkload,
boolean highPerformanceAudio, boolean reportActualDurationDisabled);
private native int getCpuCount();
private native int setCpuAffinityForCallback(int mask);
private native int getXRunCount();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ public class AudioWorkloadTestRunnerActivity extends BaseOboeTesterActivity {
private CheckBox mEnableAdpfBox;
private CheckBox mEnableAdpfWorkloadIncreaseBox;
private CheckBox mHearWorkloadBox;
private CheckBox mHighPerformanceAudioBox;
private CheckBox mDisableAdpfDurationBox;

private Button mStartButton;
private Button mStopButton;
Expand Down Expand Up @@ -79,6 +81,8 @@ protected void onCreate(Bundle savedInstanceState) {
mEnableAdpfBox = findViewById(R.id.enable_adpf);
mEnableAdpfWorkloadIncreaseBox = findViewById(R.id.enable_adpf_workload_increase);
mHearWorkloadBox = findViewById(R.id.hear_workload);
mHighPerformanceAudioBox = findViewById(R.id.high_performance_audio);
mDisableAdpfDurationBox = findViewById(R.id.disable_adpf_duration);

mStartButton = findViewById(R.id.button_start_test);
mStopButton = findViewById(R.id.button_stop_test);
Expand Down Expand Up @@ -107,9 +111,12 @@ public void startTest(View view) {
boolean adpfEnabled = mEnableAdpfBox.isChecked();
boolean adpfWorkloadIncreaseEnabled = mEnableAdpfWorkloadIncreaseBox.isChecked();
boolean hearWorkload = mHearWorkloadBox.isChecked();
boolean highPerformanceAudio = mHighPerformanceAudioBox.isChecked();
boolean reportActualDurationDisabled = mDisableAdpfDurationBox.isChecked();

int result = start(targetDurationMs, numBursts, numVoices, alternateNumVoices,
alternatingPeriodMs, adpfEnabled, adpfWorkloadIncreaseEnabled, hearWorkload);
alternatingPeriodMs, adpfEnabled, adpfWorkloadIncreaseEnabled, hearWorkload,
highPerformanceAudio, reportActualDurationDisabled);
if (result != OPERATION_SUCCESS) {
showErrorToast("start failed! Error:" + result);
return;
Expand Down Expand Up @@ -144,6 +151,8 @@ public void enableParamsUI(boolean enabled) {
mEnableAdpfBox.setEnabled(enabled);
mEnableAdpfWorkloadIncreaseBox.setEnabled(enabled);
mHearWorkloadBox.setEnabled(enabled);
mHighPerformanceAudioBox.setEnabled(enabled);
mDisableAdpfDurationBox.setEnabled(enabled);
}

private void updateResultTextView() {
Expand All @@ -160,7 +169,9 @@ private void updateResultTextView() {

public native int start(int targetDurationMs, int numBursts, int numVoices,
int alternateNumVoices, int alternatingPeriodMs, boolean adpfEnabled,
boolean adpfWorkloadIncreaseEnabled, boolean hearWorkload);
boolean adpfWorkloadIncreaseEnabled, boolean hearWorkload,
boolean highPerformanceAudio,
boolean reportActualDurationDisabled);
public native boolean stopIfDone();
public native String getStatus();
public native int stop();
Expand Down
Loading