@@ -127,13 +127,14 @@ class AudioWorkloadTest : oboe::AudioStreamDataCallback {
127127 * @param alternatingPeriodMs The period in milliseconds to alternate between numVoices and
128128 * alternateNumVoices.
129129 * @param adpfEnabled Whether to enable Adaptive Performance (ADPF) hints.
130+ * @param adpfWorkloadIncreaseEnabled Whether to use ADPF setWorkloadIncrease() API.
130131 * @param hearWorkload If true, the synthesized audio will be audible; otherwise, it's processed
131132 * silently and a sine wave will be audible instead.
132133 * @return 0 on success, or a negative Oboe error code on failure.
133134 */
134135 int32_t start (int32_t targetDurationMillis, int32_t numBursts, int32_t numVoices,
135136 int32_t alternateNumVoices, int32_t alternatingPeriodMs, bool adpfEnabled,
136- bool hearWorkload) {
137+ bool adpfWorkloadIncreaseEnabled, bool hearWorkload) {
137138 mTargetDurationMs = targetDurationMillis;
138139 mNumBursts = numBursts;
139140 mNumVoices = numVoices;
@@ -146,6 +147,7 @@ class AudioWorkloadTest : oboe::AudioStreamDataCallback {
146147 mXRunCount = 0 ;
147148 mRunning = true ;
148149 mHearWorkload = hearWorkload;
150+ mAdpfWorkloadIncreaseEnabled = adpfWorkloadIncreaseEnabled;
149151 mStream ->setPerformanceHintEnabled (adpfEnabled);
150152 mStream ->setBufferSizeInFrames (mNumBursts * mFramesPerBurst );
151153 mBufferSizeInFrames = mStream ->getBufferSizeInFrames ();
@@ -276,6 +278,7 @@ class AudioWorkloadTest : oboe::AudioStreamDataCallback {
276278 int64_t beginTimeNs = std::chrono::duration_cast<std::chrono::nanoseconds>(
277279 std::chrono::high_resolution_clock::now ().time_since_epoch ()).count ();
278280
281+ int lastVoices = mNumVoices ;
279282 int currentVoices = mNumVoices ;
280283 if (mAlternatingPeriodMs > 0 ) {
281284 int64_t timeMs = std::chrono::duration_cast<std::chrono::milliseconds>(
@@ -288,6 +291,16 @@ class AudioWorkloadTest : oboe::AudioStreamDataCallback {
288291 }
289292 }
290293
294+ if (mAdpfWorkloadIncreaseEnabled ) {
295+ if (currentVoices > lastVoices) {
296+ audioStream->notifyWorkloadIncrease (true /* cpu */ , false /* gpu */ ,
297+ kTestName .c_str ());
298+ } else if (currentVoices < lastVoices) {
299+ audioStream->notifyWorkloadReset (true /* cpu */ , false /* gpu */ ,
300+ kTestName .c_str ());
301+ }
302+ }
303+
291304 auto floatData = static_cast <float *>(audioData);
292305 int channelCount = audioStream->getChannelCount ();
293306
@@ -339,6 +352,8 @@ class AudioWorkloadTest : oboe::AudioStreamDataCallback {
339352 }
340353
341354private:
355+ const std::string kTestName = " AudioWorkloadTest" ;
356+
342357 // Member variables
343358 std::shared_ptr<oboe::AudioStream> mStream ; // Pointer to the Oboe audio stream instance
344359
@@ -357,6 +372,7 @@ class AudioWorkloadTest : oboe::AudioStreamDataCallback {
357372 std::atomic<int64_t > mLastDurationNs {0 };
358373 std::atomic<int64_t > mStartTimeMs {0 };
359374 std::atomic<bool > mHearWorkload {false };
375+ std::atomic<bool > mAdpfWorkloadIncreaseEnabled {false };
360376
361377 std::vector<CallbackStatus> mCallbackStatistics ;
362378 std::atomic<bool > mRunning {false };
0 commit comments