Skip to content

Commit

Permalink
Fix crash when starting multiple audio records.
Browse files Browse the repository at this point in the history
  • Loading branch information
greyson-signal committed Mar 20, 2023
1 parent a6d7b0c commit 6c6d4e8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
Expand Up @@ -68,7 +68,8 @@ public AudioRecorder(@NonNull Context context, @Nullable AudioRecordingHandler u
Log.i(TAG, "Running startRecording() + " + Thread.currentThread().getId());
try {
if (recorder != null) {
throw new AssertionError("We can only record once at a time.");
recordingSingle.onError(new IllegalStateException("We can only do one recording at a time!"));
return;
}

ParcelFileDescriptor fds[] = ParcelFileDescriptor.createPipe();
Expand Down
Expand Up @@ -3381,13 +3381,8 @@ public void onRecorderStarted() {
requireActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LOCKED);

voiceNoteMediaController.pausePlayback();
try {
recordingSession = new RecordingSession(audioRecorder.startRecording());
disposables.add(recordingSession);
} catch (AssertionError err) {
Log.e(TAG, "Could not start audio recording.", err);
Toast.makeText(requireContext(), R.string.ConversationActivity_unable_to_record_audio, Toast.LENGTH_SHORT).show();
}
recordingSession = new RecordingSession(audioRecorder.startRecording());
disposables.add(recordingSession);
}

@Override
Expand Down

0 comments on commit 6c6d4e8

Please sign in to comment.