Avoid truncated voice messages on some devices.

This commit is contained in:
p42ity 2024-02-09 16:01:05 +01:00
parent d8118ad945
commit 8fc08f4fdb

View file

@ -3146,6 +3146,15 @@ public class ConversationFragment extends XmppFragment
}
}
private static final Set<String> AAC_SENSITIVE_DEVICES =
new ImmutableSet.Builder<String>()
.add("FP4") // Fairphone 4 https://codeberg.org/monocles/monocles_chat/issues/133
.add("ONEPLUS A6000") // OnePlus 6 https://github.com/iNPUTmice/Conversations/issues/4329
.add("ONEPLUS A6003") // OnePlus 6 https://github.com/iNPUTmice/Conversations/issues/4329
.add("ONEPLUS A6010") // OnePlus 6T https://codeberg.org/monocles/monocles_chat/issues/133
.add("ONEPLUS A6013") // OnePlus 6T https://codeberg.org/monocles/monocles_chat/issues/133
.add("Pixel 4a") // Pixel 4a https://github.com/iNPUTmice/Conversations/issues/4223
.build();
private boolean startRecording() {
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LOCKED);
@ -3158,10 +3167,16 @@ public class ConversationFragment extends XmppFragment
mRecorder.setAudioEncodingBitRate(96000);
mRecorder.setAudioSamplingRate(48000);
} else {
mRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
mRecorder.setAudioEncodingBitRate(96000);
mRecorder.setAudioSamplingRate(44100);
if (AAC_SENSITIVE_DEVICES.contains(Build.MODEL)) {
// Changing these three settings for AAC sensitive devices might lead to sporadically truncated (cut-off) voice messages.
mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.HE_AAC);
mRecorder.setAudioSamplingRate(24000);
mRecorder.setAudioEncodingBitRate(28000);
} else {
mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
mRecorder.setAudioSamplingRate(44100);
mRecorder.setAudioEncodingBitRate(96000);
}
}
setupOutputFile();
mRecorder.setOutputFile(mOutputFile.getAbsolutePath());