Move audio compatibility check
The compatibility depends on the capture constraints, not the encoding. This will allow to add a new capture implementation with different constraints. PR #5102 <https://github.com/Genymobile/scrcpy/pull/5102>
This commit is contained in:
parent
cf09e78323
commit
5e605b9b8f
@ -121,6 +121,13 @@ public final class AudioCapture {
|
|||||||
recorder.startRecording();
|
recorder.startRecording();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void checkCompatibility() throws AudioCaptureException {
|
||||||
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.R) {
|
||||||
|
Ln.w("Audio disabled: it is not supported before Android 11");
|
||||||
|
throw new AudioCaptureException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void start() throws AudioCaptureException {
|
public void start() throws AudioCaptureException {
|
||||||
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.R) {
|
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.R) {
|
||||||
startWorkaroundAndroid11();
|
startWorkaroundAndroid11();
|
||||||
|
@ -187,6 +187,8 @@ public final class AudioEncoder implements AsyncProcessor {
|
|||||||
|
|
||||||
boolean mediaCodecStarted = false;
|
boolean mediaCodecStarted = false;
|
||||||
try {
|
try {
|
||||||
|
capture.checkCompatibility(); // throws an AudioCaptureException on error
|
||||||
|
|
||||||
Codec codec = streamer.getCodec();
|
Codec codec = streamer.getCodec();
|
||||||
mediaCodec = createMediaCodec(codec, encoderName);
|
mediaCodec = createMediaCodec(codec, encoderName);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user