Skip to content

Commit

Permalink
Catch new audio recording error states.
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholas-signal authored and alex-signal committed Feb 6, 2023
1 parent 7bae8b6 commit 10f376e
Showing 1 changed file with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3377,9 +3377,13 @@ public void onRecorderStarted() {
requireActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LOCKED);

voiceNoteMediaController.pausePlayback();
recordingSession = new RecordingSession(audioRecorder.startRecording());

disposables.add(recordingSession);
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();
}
}

@Override
Expand All @@ -3398,8 +3402,9 @@ public void onRecorderFinished() {

requireActivity().getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
requireActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);

recordingSession.completeRecording();
if (recordingSession != null) {
recordingSession.completeRecording();
}
}

@Override
Expand Down

0 comments on commit 10f376e

Please sign in to comment.