Move the voice pipelines into core
Capture processing, the jitter buffer and decoding were desktop classes, so any other platform would have had to copy them. They now live in core and reach the platform only through two interfaces: - AudioIo lists devices and opens capture/playback lines; the desktop's AudioDevices implements it over PipeWire and Java Sound. - OpusCodec creates encoders and decoders; the desktop binds libopus through the FFM API as before. DesktopVoiceInput becomes CaptureVoiceInput unchanged in behaviour. DesktopVoiceOutput splits into VoiceStream, one speaker's jitter buffer and decoder, paced by whoever pulls it, and StreamingVoiceOutput around it. Speakers reach the device either on a line each (the desktop, so each shows up in the PipeWire mixer) or mixed onto one shared line, as mobile audio APIs want. The settings dialog's device lists and microphone test now go through the AudioBackend instead of desktop classes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,9 +1,8 @@
|
||||
package com.ts3client.ui;
|
||||
|
||||
import com.ts3client.audio.AudioBackend;
|
||||
import com.ts3client.audio.AudioPlayback;
|
||||
import com.ts3client.audio.VoiceInput;
|
||||
import com.ts3client.audio.desktop.AudioDevices;
|
||||
import com.ts3client.audio.desktop.AudioPlayback;
|
||||
import com.ts3client.audio.desktop.DesktopVoiceInput;
|
||||
import com.ts3client.config.Settings;
|
||||
|
||||
import javax.swing.SwingUtilities;
|
||||
@@ -13,7 +12,7 @@ import java.util.function.Consumer;
|
||||
/**
|
||||
* Drives the settings dialog's microphone test from a real capture chain.
|
||||
*
|
||||
* <p>The dialog runs its own {@link DesktopVoiceInput} rather than borrowing the connected
|
||||
* <p>The dialog runs its own {@link VoiceInput} rather than borrowing the connected
|
||||
* one, whose listeners belong to the connection. Because it is the same class that feeds
|
||||
* the server, the level and the gate shown here are exactly what would be transmitted —
|
||||
* pre-processing, voice detection, hangover and pre-roll included.
|
||||
@@ -29,7 +28,8 @@ final class MicrophoneTest {
|
||||
private final Consumer<Double> onLevel;
|
||||
private final Consumer<Boolean> onTransmitting;
|
||||
|
||||
private DesktopVoiceInput mic;
|
||||
private final AudioBackend audio;
|
||||
private VoiceInput mic;
|
||||
|
||||
private final ArrayBlockingQueue<byte[]> loopbackQueue =
|
||||
new ArrayBlockingQueue<>(LOOPBACK_QUEUE_FRAMES);
|
||||
@@ -38,7 +38,8 @@ final class MicrophoneTest {
|
||||
private Thread loopbackThread;
|
||||
private String outputDevice = "";
|
||||
|
||||
MicrophoneTest(Consumer<Double> onLevel, Consumer<Boolean> onTransmitting) {
|
||||
MicrophoneTest(AudioBackend audio, Consumer<Double> onLevel, Consumer<Boolean> onTransmitting) {
|
||||
this.audio = audio;
|
||||
this.onLevel = onLevel;
|
||||
this.onTransmitting = onTransmitting;
|
||||
}
|
||||
@@ -55,7 +56,7 @@ final class MicrophoneTest {
|
||||
*/
|
||||
boolean start(Settings settings) {
|
||||
stop();
|
||||
DesktopVoiceInput input = new DesktopVoiceInput(settings);
|
||||
VoiceInput input = audio.createInput(settings);
|
||||
input.setLevelListener(db -> SwingUtilities.invokeLater(() -> onLevel.accept(db)));
|
||||
input.setTalkListener(talking -> SwingUtilities.invokeLater(() -> onTransmitting.accept(talking)));
|
||||
input.setMonitorListener(this::enqueueForLoopback);
|
||||
@@ -133,7 +134,7 @@ final class MicrophoneTest {
|
||||
try {
|
||||
// The monitored frames are mono for voice; ask for a matching line so no
|
||||
// channel juggling is needed, and up-mix only if the device insists on stereo.
|
||||
line = AudioDevices.openPlayback(outputDevice, 1);
|
||||
line = audio.io().openPlayback(outputDevice, 1);
|
||||
line.start();
|
||||
int channels = line.channels();
|
||||
while (loopbackRunning) {
|
||||
|
||||
Reference in New Issue
Block a user