mirror of
https://github.com/Genymobile/scrcpy
synced 2024-11-11 01:10:32 +00:00
Move audio source value
The MediaRecorder constant should not belong to the AudioSource enum. This will allow to add a new AudioSource which has no meaningful MediaRecorder audio source value. PR #5102 <https://github.com/Genymobile/scrcpy/pull/5102>
This commit is contained in:
parent
0f076083e8
commit
53c6eb66ea
@ -11,6 +11,7 @@ import android.content.ComponentName;
|
||||
import android.content.Intent;
|
||||
import android.media.AudioRecord;
|
||||
import android.media.MediaCodec;
|
||||
import android.media.MediaRecorder;
|
||||
import android.os.Build;
|
||||
import android.os.SystemClock;
|
||||
|
||||
@ -30,7 +31,18 @@ public class AudioDirectCapture implements AudioCapture {
|
||||
private AudioRecordReader reader;
|
||||
|
||||
public AudioDirectCapture(AudioSource audioSource) {
|
||||
this.audioSource = audioSource.value();
|
||||
this.audioSource = getAudioSourceValue(audioSource);
|
||||
}
|
||||
|
||||
private static int getAudioSourceValue(AudioSource audioSource) {
|
||||
switch (audioSource) {
|
||||
case OUTPUT:
|
||||
return MediaRecorder.AudioSource.REMOTE_SUBMIX;
|
||||
case MIC:
|
||||
return MediaRecorder.AudioSource.MIC;
|
||||
default:
|
||||
throw new IllegalArgumentException("Unsupported audio source: " + audioSource);
|
||||
}
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.M)
|
||||
|
@ -1,21 +1,13 @@
|
||||
package com.genymobile.scrcpy.audio;
|
||||
|
||||
import android.media.MediaRecorder;
|
||||
|
||||
public enum AudioSource {
|
||||
OUTPUT("output", MediaRecorder.AudioSource.REMOTE_SUBMIX),
|
||||
MIC("mic", MediaRecorder.AudioSource.MIC);
|
||||
OUTPUT("output"),
|
||||
MIC("mic");
|
||||
|
||||
private final String name;
|
||||
private final int value;
|
||||
|
||||
AudioSource(String name, int value) {
|
||||
AudioSource(String name) {
|
||||
this.name = name;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
int value() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public static AudioSource findByName(String name) {
|
||||
|
Loading…
Reference in New Issue
Block a user