Skip to content

Commit 9171846

Browse files
authored
OboeTester: save all WAV files in Data Paths test (#2207)
Delete old files when the test starts. Move message about saved files to Summary.
1 parent 22f0a85 commit 9171846

4 files changed

Lines changed: 47 additions & 8 deletions

File tree

apps/OboeTester/app/src/main/cpp/analyzer/BaseSineAnalyzer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ class BaseSineAnalyzer : public LoopbackProcessor {
165165

166166
ALOGD("%s(), phaseOffset = %f\n", __func__, mPhaseOffset);
167167
if (mPhaseOffset != kPhaseInvalid) {
168-
// One pole averaging filter.
168+
// One pole averaging filter for magnitude.
169169
setMagnitude((mMagnitude * (1.0 - coefficient)) + (magnitude * coefficient));
170170
}
171171
resetAccumulator();

apps/OboeTester/app/src/main/java/com/mobileer/oboetester/AutomatedGlitchActivity.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@ public void runTest() {
110110

111111
compareFailedTestsWithNearestPassingTest();
112112

113+
reportSavedWaveFiles();
114+
113115
} catch (InterruptedException e) {
114116
compareFailedTestsWithNearestPassingTest();
115117

apps/OboeTester/app/src/main/java/com/mobileer/oboetester/BaseAutoGlitchActivity.java

Lines changed: 42 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,10 @@ protected TestResult testCurrentConfigurations() throws InterruptedException {
273273
}
274274

275275
log("========================== #" + getTestCount());
276+
if (getTestCount() == 1) {
277+
deleteOldWaveFiles();
278+
}
279+
276280
int result = 0;
277281
StreamConfiguration requestedInConfig = mAudioInputTester.requestedConfiguration;
278282
StreamConfiguration requestedOutConfig = mAudioOutTester.requestedConfiguration;
@@ -385,13 +389,13 @@ protected TestResult testCurrentConfigurations() throws InterruptedException {
385389
appendFailedSummary(" " + getConfigText(actualInConfig) + "\n");
386390
appendFailedSummary(" " + getConfigText(actualOutConfig) + "\n");
387391
appendFailedSummary(" " + resultText + "\n");
388-
saveRecordingAsWave();
389392
mAutomatedTestRunner.incrementFailCount();
390393
result = TEST_RESULT_FAILED;
391394
} else {
392395
mAutomatedTestRunner.incrementPassCount();
393396
result = TEST_RESULT_PASSED;
394397
}
398+
saveRecordingAsWave(); // Save recording for both pass and fail results.
395399
}
396400
mAutomatedTestRunner.flushLog();
397401

@@ -434,14 +438,45 @@ void testPerformancePaths() throws InterruptedException {
434438
requestedOutConfig.setMMap(false);
435439
}
436440

441+
File getRecordingDir() {
442+
return getExternalFilesDir(Environment.DIRECTORY_MUSIC);
443+
}
444+
445+
void reportSavedWaveFiles() {
446+
logAnalysis("\n --------\n"
447+
+ "Audio for each test saved in:\n "
448+
+ getRecordingDir().getAbsolutePath()
449+
+ "/glitch_{###}.wav\n");
450+
}
451+
437452
private void saveRecordingAsWave() {
438-
File recordingDir = getExternalFilesDir(Environment.DIRECTORY_MUSIC);
439-
File waveFile = new File(recordingDir, String.format("glitch_%03d.wav", getTestCount()));
453+
File waveFile = new File(getRecordingDir(),
454+
String.format("glitch_%03d.wav", getTestCount()));
440455
int saveResult = saveWaveFile(waveFile.getAbsolutePath());
441-
if (saveResult > 0) {
442-
appendFailedSummary("Saved in " + waveFile.getAbsolutePath() + "\n");
443-
} else {
444-
appendFailedSummary("saveWaveFile() returned " + saveResult + "\n");
456+
if (saveResult <= 0) {
457+
appendSummary("ERROR: saving "
458+
+ waveFile.getAbsolutePath()
459+
+ " returned " + saveResult + "\n");
460+
}
461+
}
462+
463+
/**
464+
* Delete all the previously saved WAV files so the user does not
465+
* debug obsolete data.
466+
*/
467+
private void deleteOldWaveFiles() {
468+
File recordingDir = getRecordingDir();
469+
if (recordingDir.exists()) {
470+
File[] files = recordingDir.listFiles();
471+
if (files != null) {
472+
for (File file : files) {
473+
if (file.isFile()) {
474+
if (!file.delete()) {
475+
appendFailedSummary("Failed to delete file: " + file.getAbsolutePath());
476+
}
477+
}
478+
}
479+
}
445480
}
446481
}
447482

apps/OboeTester/app/src/main/java/com/mobileer/oboetester/TestDataPathsActivity.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -873,6 +873,8 @@ public void runTest() {
873873

874874
compareFailedTestsWithNearestPassingTest();
875875

876+
reportSavedWaveFiles();
877+
876878
} catch (InterruptedException e) {
877879
compareFailedTestsWithNearestPassingTest();
878880
} catch (Exception e) {

0 commit comments

Comments
 (0)