Fix CameraX crash.
This commit is contained in:
parent
c7f76c5d1c
commit
daeb823399
1 changed files with 15 additions and 4 deletions
|
@ -31,7 +31,6 @@ import android.media.MediaRecorder.AudioSource;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.HandlerThread;
|
import android.os.HandlerThread;
|
||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
import android.util.Log;
|
|
||||||
import android.util.Size;
|
import android.util.Size;
|
||||||
import android.view.Display;
|
import android.view.Display;
|
||||||
import android.view.Surface;
|
import android.view.Surface;
|
||||||
|
@ -58,6 +57,7 @@ import androidx.camera.core.UseCaseConfig;
|
||||||
import androidx.camera.core.VideoCaptureConfig;
|
import androidx.camera.core.VideoCaptureConfig;
|
||||||
import androidx.camera.core.impl.utils.executor.CameraXExecutors;
|
import androidx.camera.core.impl.utils.executor.CameraXExecutors;
|
||||||
|
|
||||||
|
import org.thoughtcrime.securesms.logging.Log;
|
||||||
import org.thoughtcrime.securesms.video.VideoUtil;
|
import org.thoughtcrime.securesms.video.VideoUtil;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
@ -148,7 +148,6 @@ public class VideoCapture extends UseCase {
|
||||||
/** Surface the camera writes to, which the videoEncoder uses as input. */
|
/** Surface the camera writes to, which the videoEncoder uses as input. */
|
||||||
Surface mCameraSurface;
|
Surface mCameraSurface;
|
||||||
/** audio raw data */
|
/** audio raw data */
|
||||||
@NonNull
|
|
||||||
private AudioRecord mAudioRecorder;
|
private AudioRecord mAudioRecorder;
|
||||||
private int mAudioBufferSize;
|
private int mAudioBufferSize;
|
||||||
private boolean mIsRecording = false;
|
private boolean mIsRecording = false;
|
||||||
|
@ -298,7 +297,13 @@ public class VideoCapture extends UseCase {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// audioRecord start
|
// audioRecord start
|
||||||
|
// Begin Signal Custom Code Block
|
||||||
|
if (mAudioRecorder != null) {
|
||||||
mAudioRecorder.startRecording();
|
mAudioRecorder.startRecording();
|
||||||
|
} else {
|
||||||
|
Log.w(TAG, "Missing audio recorder in start()!");
|
||||||
|
}
|
||||||
|
// End Signal Custom Code Block
|
||||||
} catch (IllegalStateException e) {
|
} catch (IllegalStateException e) {
|
||||||
postListener.onError(VideoCaptureError.ENCODER_ERROR, "AudioRecorder start fail", e);
|
postListener.onError(VideoCaptureError.ENCODER_ERROR, "AudioRecorder start fail", e);
|
||||||
return;
|
return;
|
||||||
|
@ -753,7 +758,13 @@ public class VideoCapture extends UseCase {
|
||||||
// Audio Stop
|
// Audio Stop
|
||||||
try {
|
try {
|
||||||
Log.i(TAG, "audioRecorder stop");
|
Log.i(TAG, "audioRecorder stop");
|
||||||
|
// Begin Signal Custom Code Block
|
||||||
|
if (mAudioRecorder != null) {
|
||||||
mAudioRecorder.stop();
|
mAudioRecorder.stop();
|
||||||
|
} else {
|
||||||
|
Log.w(TAG, "Missing audio recorder in stop()!");
|
||||||
|
}
|
||||||
|
// End Signal Custom Code Block
|
||||||
} catch (IllegalStateException e) {
|
} catch (IllegalStateException e) {
|
||||||
videoSavedListener.onError(
|
videoSavedListener.onError(
|
||||||
VideoCaptureError.ENCODER_ERROR, "Audio recorder stop failed!", e);
|
VideoCaptureError.ENCODER_ERROR, "Audio recorder stop failed!", e);
|
||||||
|
|
Loading…
Add table
Reference in a new issue