mirror of
https://github.com/Genymobile/scrcpy
synced 2024-11-11 01:10:32 +00:00
Rename audio capture exception
The AudioCaptureForegroundException was very specific. Rename it to AudioCaptureException to support other capture failures. PR #5102 <https://github.com/Genymobile/scrcpy/pull/5102>
This commit is contained in:
parent
39132ff2dd
commit
3b8ec0c38d
@ -89,7 +89,7 @@ public final class AudioCapture {
|
||||
ServiceManager.getActivityManager().forceStopPackage(FakeContext.PACKAGE_NAME);
|
||||
}
|
||||
|
||||
private void tryStartRecording(int attempts, int delayMs) throws AudioCaptureForegroundException {
|
||||
private void tryStartRecording(int attempts, int delayMs) throws AudioCaptureException {
|
||||
while (attempts-- > 0) {
|
||||
// Wait for activity to start
|
||||
SystemClock.sleep(delayMs);
|
||||
@ -101,7 +101,7 @@ public final class AudioCapture {
|
||||
Ln.e("Failed to start audio capture");
|
||||
Ln.e("On Android 11, audio capture must be started in the foreground, make sure that the device is unlocked when starting "
|
||||
+ "scrcpy.");
|
||||
throw new AudioCaptureForegroundException();
|
||||
throw new AudioCaptureException();
|
||||
} else {
|
||||
Ln.d("Failed to start audio capture, retrying...");
|
||||
}
|
||||
@ -121,7 +121,7 @@ public final class AudioCapture {
|
||||
recorder.startRecording();
|
||||
}
|
||||
|
||||
public void start() throws AudioCaptureForegroundException {
|
||||
public void start() throws AudioCaptureException {
|
||||
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.R) {
|
||||
startWorkaroundAndroid11();
|
||||
try {
|
||||
|
@ -0,0 +1,12 @@
|
||||
package com.genymobile.scrcpy.audio;
|
||||
|
||||
/**
|
||||
* Exception for any audio capture issue.
|
||||
* <p/>
|
||||
* This includes the case where audio capture failed on Android 11 specifically because the running App (Shell) was not in foreground.
|
||||
* <p/>
|
||||
* Its purpose is to disable audio without errors (that's why the exception is empty, any error message must be printed by the caller before
|
||||
* throwing the exception).
|
||||
*/
|
||||
public class AudioCaptureException extends Exception {
|
||||
}
|
@ -1,7 +0,0 @@
|
||||
package com.genymobile.scrcpy.audio;
|
||||
|
||||
/**
|
||||
* Exception thrown if audio capture failed on Android 11 specifically because the running App (shell) was not in foreground.
|
||||
*/
|
||||
public class AudioCaptureForegroundException extends Exception {
|
||||
}
|
@ -132,7 +132,7 @@ public final class AudioEncoder implements AsyncProcessor {
|
||||
} catch (ConfigurationException e) {
|
||||
// Do not print stack trace, a user-friendly error-message has already been logged
|
||||
fatalError = true;
|
||||
} catch (AudioCaptureForegroundException e) {
|
||||
} catch (AudioCaptureException e) {
|
||||
// Do not print stack trace, a user-friendly error-message has already been logged
|
||||
} catch (IOException e) {
|
||||
Ln.e("Audio encoding error", e);
|
||||
@ -176,7 +176,7 @@ public final class AudioEncoder implements AsyncProcessor {
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.M)
|
||||
private void encode() throws IOException, ConfigurationException, AudioCaptureForegroundException {
|
||||
private void encode() throws IOException, ConfigurationException, AudioCaptureException {
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.R) {
|
||||
Ln.w("Audio disabled: it is not supported before Android 11");
|
||||
streamer.writeDisableStream(false);
|
||||
|
@ -23,7 +23,7 @@ public final class AudioRawRecorder implements AsyncProcessor {
|
||||
this.streamer = streamer;
|
||||
}
|
||||
|
||||
private void record() throws IOException, AudioCaptureForegroundException {
|
||||
private void record() throws IOException, AudioCaptureException {
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.R) {
|
||||
Ln.w("Audio disabled: it is not supported before Android 11");
|
||||
streamer.writeDisableStream(false);
|
||||
@ -69,7 +69,7 @@ public final class AudioRawRecorder implements AsyncProcessor {
|
||||
boolean fatalError = false;
|
||||
try {
|
||||
record();
|
||||
} catch (AudioCaptureForegroundException e) {
|
||||
} catch (AudioCaptureException e) {
|
||||
// Do not print stack trace, a user-friendly error-message has already been logged
|
||||
} catch (Throwable t) {
|
||||
Ln.e("Audio recording error", t);
|
||||
|
Loading…
Reference in New Issue
Block a user