Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OboeTester: save a WAVE file when DataPaths test fails #2045

Merged
merged 2 commits into from
Jun 27, 2024
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
5 changes: 4 additions & 1 deletion apps/OboeTester/app/src/main/cpp/FullDuplexAnalyzer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,13 @@ oboe::DataCallbackResult FullDuplexAnalyzer::onBothStreamsReadyFloat(
(void) getLoopbackProcessor()->process(inputFloat, inputStride, numInputFrames,
outputFloat, outputStride, numOutputFrames);

// write the first channel of output and input to the stereo recorder
// Save data for later analysis or for writing to a WAVE file.
if (mRecording != nullptr) {
float buffer[2];
int numBoth = std::min(numInputFrames, numOutputFrames);
// Offset to the selected channels that we are analyzing.
inputFloat += getLoopbackProcessor()->getInputChannel();
outputFloat += getLoopbackProcessor()->getOutputChannel();
for (int i = 0; i < numBoth; i++) {
buffer[0] = *outputFloat;
outputFloat += outputStride;
Expand Down
20 changes: 1 addition & 19 deletions apps/OboeTester/app/src/main/cpp/analyzer/BaseSineAnalyzer.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,22 +58,6 @@ class BaseSineAnalyzer : public LoopbackProcessor {
return mMagnitude;
}

void setInputChannel(int inputChannel) {
mInputChannel = inputChannel;
}

int getInputChannel() const {
return mInputChannel;
}

void setOutputChannel(int outputChannel) {
mOutputChannel = outputChannel;
}

int getOutputChannel() const {
return mOutputChannel;
}

void setNoiseAmplitude(double noiseAmplitude) {
mNoiseAmplitude = noiseAmplitude;
}
Expand Down Expand Up @@ -113,7 +97,7 @@ class BaseSineAnalyzer : public LoopbackProcessor {
// ALOGD("sin(%f) = %f, %f\n", mOutputPhase, sinOut, kPhaseIncrement);
}
for (int i = 0; i < channelCount; i++) {
frameData[i] = (i == mOutputChannel) ? output : 0.0f;
frameData[i] = (i == getOutputChannel()) ? output : 0.0f;
}
return RESULT_OK;
}
Expand Down Expand Up @@ -232,8 +216,6 @@ class BaseSineAnalyzer : public LoopbackProcessor {
InfiniteRecording<float> mInfiniteRecording;

private:
int32_t mInputChannel = 0;
int32_t mOutputChannel = 0;
float mTolerance = 0.10; // scaled from 0.0 to 1.0

float mNoiseAmplitude = 0.00; // Used to experiment with warbling caused by DRC.
Expand Down
31 changes: 31 additions & 0 deletions apps/OboeTester/app/src/main/cpp/analyzer/LatencyAnalyzer.h
Original file line number Diff line number Diff line change
Expand Up @@ -428,10 +428,41 @@ class LoopbackProcessor {
reset();
}

/**
* Some analyzers may only look at one channel.
* You can optionally specify that channel here.
*
* @param inputChannel
*/
void setInputChannel(int inputChannel) {
mInputChannel = inputChannel;
}

int getInputChannel() const {
return mInputChannel;
}

/**
* Some analyzers may only generate one channel.
* You can optionally specify that channel here.
*
* @param outputChannel
*/
void setOutputChannel(int outputChannel) {
mOutputChannel = outputChannel;
}

int getOutputChannel() const {
return mOutputChannel;
}

protected:
int32_t mResetCount = 0;

private:

int32_t mInputChannel = 0;
int32_t mOutputChannel = 0;
int32_t mSampleRate = kDefaultSampleRate;
int32_t mResult = 0;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@
import android.media.AudioDeviceInfo;
import android.media.AudioManager;
import android.os.Bundle;
import android.os.Environment;

import androidx.annotation.Nullable;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Locale;
Expand Down Expand Up @@ -377,13 +379,13 @@ protected TestResult testCurrentConfigurations() throws InterruptedException {
appendFailedSummary(" " + getConfigText(actualInConfig) + "\n");
appendFailedSummary(" " + getConfigText(actualOutConfig) + "\n");
appendFailedSummary(" " + resultText + "\n");
saveRecordingAsWave();
mAutomatedTestRunner.incrementFailCount();
result = TEST_RESULT_FAILED;
} else {
mAutomatedTestRunner.incrementPassCount();
result = TEST_RESULT_PASSED;
}

}
mAutomatedTestRunner.flushLog();

Expand All @@ -397,6 +399,17 @@ protected TestResult testCurrentConfigurations() throws InterruptedException {
return testResult;
}

private void saveRecordingAsWave() {
File recordingDir = getExternalFilesDir(Environment.DIRECTORY_MUSIC);
File waveFile = new File(recordingDir, String.format("glitch_%03d.wav", getTestCount()));
int saveResult = saveWaveFile(waveFile.getAbsolutePath());
if (saveResult > 0) {
appendFailedSummary("Saved in " + waveFile.getAbsolutePath() + "\n");
} else {
appendFailedSummary("saveWaveFile() returned " + saveResult + "\n");
}
}

protected int getTestCount() {
return mAutomatedTestRunner.getTestCount();
}
Expand Down