Skip to content

Commit 22f0a85

Browse files
authored
OboeTester - prevent null crash with automation (#2203)
I tried to prevent getResetCount() from being called when the stream is not ready. But it was hard to track down the offending call. So I just prevented the NULL crash. I then added a dump of the frames read and written so we can see if recording is blocked due to permissions. Surprisingly the test semed to run OK after this patch. Fixes #2201
1 parent 609da81 commit 22f0a85

3 files changed

Lines changed: 16 additions & 2 deletions

File tree

apps/OboeTester/app/src/main/cpp/NativeAudioContext.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,15 @@ class ActivityFullDuplex : public ActivityContext {
520520
virtual FullDuplexAnalyzer *getFullDuplexAnalyzer() = 0;
521521

522522
int32_t getResetCount() {
523-
return getFullDuplexAnalyzer()->getLoopbackProcessor()->getResetCount();
523+
auto analyzer = getFullDuplexAnalyzer();
524+
if (analyzer == nullptr) {
525+
return -1;
526+
}
527+
auto processor = analyzer->getLoopbackProcessor();
528+
if (processor == nullptr) {
529+
return -1;
530+
}
531+
return processor->getResetCount();
524532
}
525533

526534
protected:

apps/OboeTester/app/src/main/cpp/jni-bridge.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -803,7 +803,11 @@ Java_com_mobileer_oboetester_AnalyzerActivity_isAnalyzerDone(JNIEnv *env,
803803
JNIEXPORT jint JNICALL
804804
Java_com_mobileer_oboetester_AnalyzerActivity_getResetCount(JNIEnv *env,
805805
jobject instance) {
806-
return ((ActivityFullDuplex *)engine.getCurrentActivity())->getResetCount();
806+
auto activity = (ActivityFullDuplex *)engine.getCurrentActivity();
807+
if (activity == nullptr) {
808+
return -1;
809+
}
810+
return activity->getResetCount();
807811
}
808812

809813
// ==========================================================================

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ protected String getCommonTestReport() {
8484
AudioStreamBase inStream = mAudioInputTester.getCurrentAudioStream();
8585
report.append(String.format(Locale.getDefault(), "in.burst.frames = %d\n", inStream.getFramesPerBurst()));
8686
report.append(String.format(Locale.getDefault(), "in.xruns = %d\n", inStream.getXRunCount()));
87+
report.append(String.format(Locale.getDefault(), "in.frames.read = %d\n", inStream.getFramesRead()));
8788

8889
// OUTPUT
8990
report.append(mAudioOutTester.actualConfiguration.dump());
@@ -94,6 +95,7 @@ protected String getCommonTestReport() {
9495
int bufferCapacity = outStream.getBufferCapacityInFrames();
9596
report.append(String.format(Locale.getDefault(), "out.buffer.capacity.frames = %d\n", bufferCapacity));
9697
report.append(String.format(Locale.getDefault(), "out.xruns = %d\n", outStream.getXRunCount()));
98+
report.append(String.format(Locale.getDefault(), "out.frames.written = %d\n", outStream.getFramesWritten()));
9799

98100
return report.toString();
99101
}

0 commit comments

Comments
 (0)