Skip to content

Commit

Permalink
feat(client): debug print supported data lines when capture device is…
Browse files Browse the repository at this point in the history
… not available
  • Loading branch information
Apehum committed Nov 16, 2024
1 parent 7b0cdbf commit 89df241
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,18 @@
import su.plo.voice.api.client.audio.capture.AudioCapture;
import su.plo.voice.api.client.audio.capture.ClientActivation;
import su.plo.voice.api.client.audio.capture.ClientActivationManager;
import su.plo.voice.api.client.audio.device.AudioDevice;
import su.plo.voice.api.client.audio.device.DeviceManager;
import su.plo.voice.api.client.audio.device.DeviceType;
import su.plo.voice.api.client.audio.device.InputDevice;
import su.plo.voice.api.client.connection.ServerInfo;
import su.plo.voice.api.client.event.audio.capture.*;
import su.plo.voice.api.client.event.audio.capture.AudioCaptureEvent;
import su.plo.voice.api.client.event.audio.capture.AudioCaptureInitializeEvent;
import su.plo.voice.api.client.event.audio.capture.AudioCaptureProcessedEvent;
import su.plo.voice.api.client.event.audio.capture.AudioCaptureStartEvent;
import su.plo.voice.api.client.event.audio.capture.AudioCaptureStopEvent;
import su.plo.voice.api.encryption.Encryption;
import su.plo.voice.api.encryption.EncryptionException;
import su.plo.voice.api.util.AudioUtil;
import su.plo.voice.client.audio.device.JavaxInputDeviceFactory;
import su.plo.voice.client.audio.filter.StereoToMonoFilter;
import su.plo.voice.client.config.VoiceClientConfig;
import su.plo.voice.client.mac.AVAuthorizationStatus;
Expand All @@ -41,7 +44,10 @@
import su.plo.voice.proto.packets.udp.serverbound.PlayerAudioPacket;

import javax.sound.sampled.AudioFormat;
import java.util.*;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.UUID;

public final class VoiceAudioCapture implements AudioCapture {

Expand Down Expand Up @@ -123,6 +129,7 @@ public void initialize(@NotNull ServerInfo serverInfo) {
devices.setInputDevice(inputDevice);
} catch (Exception e) {
LOGGER.error("Failed to open input device", e);
JavaxInputDeviceFactory.printSupportedLines();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,45 @@
import com.google.common.collect.ImmutableList;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import su.plo.voice.BaseVoice;
import su.plo.voice.api.client.PlasmoVoiceClient;
import su.plo.voice.api.client.audio.device.AudioDevice;
import su.plo.voice.api.client.audio.device.DeviceException;
import su.plo.voice.api.client.audio.device.DeviceFactory;

import javax.sound.sampled.*;
import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.DataLine;
import javax.sound.sampled.Line;
import javax.sound.sampled.Mixer;
import javax.sound.sampled.TargetDataLine;
import java.util.ArrayList;
import java.util.List;

import static com.google.common.base.Preconditions.checkNotNull;

public final class JavaxInputDeviceFactory implements DeviceFactory {

public static void printSupportedLines() {
BaseVoice.DEBUG_LOGGER.log("Supported target data lines:");

Mixer.Info[] mixers = AudioSystem.getMixerInfo();
for (Mixer.Info mixerInfo : mixers) {
Mixer mixer = AudioSystem.getMixer(mixerInfo);
Line.Info lineInfo = new Line.Info(TargetDataLine.class);

if (mixer.isLineSupported(lineInfo)) {
for (Line.Info info : mixer.getTargetLineInfo()) {
BaseVoice.DEBUG_LOGGER.log(info.toString());
DataLine.Info dataInfo = (DataLine.Info) info;
for (AudioFormat dataFormat : dataInfo.getFormats()) {
BaseVoice.DEBUG_LOGGER.log(dataFormat.toString());
}
}
}
}
}

private final PlasmoVoiceClient client;

public JavaxInputDeviceFactory(PlasmoVoiceClient client) {
Expand Down

0 comments on commit 89df241

Please sign in to comment.