Skip to content

Commit

Permalink
Fix CameraX crash.
Browse files Browse the repository at this point in the history
  • Loading branch information
greyson-signal committed Oct 19, 2019
1 parent c7f76c5 commit daeb823
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions src/org/thoughtcrime/securesms/mediasend/camerax/VideoCapture.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import android.os.Handler;
import android.os.HandlerThread;
import android.os.Looper;
import android.util.Log;
import android.util.Size;
import android.view.Display;
import android.view.Surface;
Expand All @@ -58,6 +57,7 @@
import androidx.camera.core.VideoCaptureConfig;
import androidx.camera.core.impl.utils.executor.CameraXExecutors;

import org.thoughtcrime.securesms.logging.Log;
import org.thoughtcrime.securesms.video.VideoUtil;

import java.io.File;
Expand Down Expand Up @@ -148,7 +148,6 @@ public class VideoCapture extends UseCase {
/** Surface the camera writes to, which the videoEncoder uses as input. */
Surface mCameraSurface;
/** audio raw data */
@NonNull
private AudioRecord mAudioRecorder;
private int mAudioBufferSize;
private boolean mIsRecording = false;
Expand Down Expand Up @@ -298,7 +297,13 @@ public void startRecording(

try {
// audioRecord start
mAudioRecorder.startRecording();
// Begin Signal Custom Code Block
if (mAudioRecorder != null) {
mAudioRecorder.startRecording();
} else {
Log.w(TAG, "Missing audio recorder in start()!");
}
// End Signal Custom Code Block
} catch (IllegalStateException e) {
postListener.onError(VideoCaptureError.ENCODER_ERROR, "AudioRecorder start fail", e);
return;
Expand Down Expand Up @@ -753,7 +758,13 @@ boolean audioEncode(OnVideoSavedListener videoSavedListener) {
// Audio Stop
try {
Log.i(TAG, "audioRecorder stop");
mAudioRecorder.stop();
// Begin Signal Custom Code Block
if (mAudioRecorder != null) {
mAudioRecorder.stop();
} else {
Log.w(TAG, "Missing audio recorder in stop()!");
}
// End Signal Custom Code Block
} catch (IllegalStateException e) {
videoSavedListener.onError(
VideoCaptureError.ENCODER_ERROR, "Audio recorder stop failed!", e);
Expand Down

0 comments on commit daeb823

Please sign in to comment.