audio record: fix getPortId() after release

Some race condition can cause AudioRecordingMonitorImpl to call
getPortId() on the client object after it has been released causing
an exception to be thrown by the JNI.

Test: Use audio Recorder app and check that no exception is thrown
when recording stops

Change-Id: I6cc1aee0a2ccae879e2cb5df7af757f33436d1f3
This commit is contained in:
Eric Laurent
2019-07-12 17:29:33 -07:00
parent b3f0c30231
commit f361061451
2 changed files with 6 additions and 0 deletions

View File

@@ -1788,6 +1788,9 @@ public class AudioRecord implements AudioRouting, MicrophoneDirection,
* @hide
*/
public int getPortId() {
if (mNativeRecorderInJavaObj == 0) {
return 0;
}
return native_getPortId();
}

View File

@@ -1624,6 +1624,9 @@ public class MediaRecorder implements AudioRouting,
* @hide
*/
public int getPortId() {
if (mNativeContext == 0) {
return 0;
}
return native_getPortId();
}