Discard voice note recording on error.

This commit is contained in:
Nicholas Tinsley
2023-06-22 13:32:27 -04:00
parent bc1fbd9b6c
commit 88f50da4fb
2 changed files with 3 additions and 2 deletions

View File

@@ -48,14 +48,14 @@ public class AudioRecorder {
if (this.uiHandler != null) {
onAudioFocusChangeListener = focusChange -> {
if (focusChange == AudioManager.AUDIOFOCUS_LOSS) {
Log.i(TAG, "Audio focus change " + focusChange + " stopping recording");
Log.i(TAG, "Audio focus change " + focusChange + " stopping recording via UI handler.");
this.uiHandler.onRecordCanceled(false);
}
};
} else {
onAudioFocusChangeListener = focusChange -> {
if (focusChange == AudioManager.AUDIOFOCUS_LOSS) {
Log.i(TAG, "Audio focus change " + focusChange + " stopping recording");
Log.i(TAG, "Audio focus change " + focusChange + " stopping recording.");
stopRecording();
}
};

View File

@@ -3730,6 +3730,7 @@ public class ConversationParentFragment extends Fragment
public void onError(Throwable t) {
Toast.makeText(requireContext(), R.string.ConversationActivity_unable_to_record_audio, Toast.LENGTH_LONG).show();
Log.e(TAG, "Error in RecordingSession.", t);
recordingSession.discardRecording();
recordingSession.dispose();
recordingSession = null;
}