Microphone changes
This commit is contained in:
+5
-4
@@ -198,7 +198,7 @@ public class LocalTeamspeakClientSocket
|
||||
waitForState(ClientConnectionState.CONNECTED, timeout);
|
||||
|
||||
microphoneThread = new HighPrecisionRecurrentTask(
|
||||
1000,
|
||||
20,
|
||||
0.020F,
|
||||
new MicrophoneTask()
|
||||
);
|
||||
@@ -328,11 +328,10 @@ public class LocalTeamspeakClientSocket
|
||||
private class MicrophoneTask implements Runnable {
|
||||
@Override
|
||||
public void run() {
|
||||
PacketBody0Voice voice = new PacketBody0Voice(getRole().getOut());
|
||||
Microphone microphone;
|
||||
|
||||
if (!isConnected()) return;
|
||||
|
||||
Microphone microphone;
|
||||
|
||||
// Attempt to get the current microphone instance, saving it in a variable to prevent
|
||||
// any race conditions by accessing the parent class' this.microphone.
|
||||
if ((microphone = LocalTeamspeakClientSocket.this.microphone) == null)
|
||||
@@ -342,6 +341,8 @@ public class LocalTeamspeakClientSocket
|
||||
// TODO
|
||||
// Set a state and send a muted event
|
||||
} else if (microphone.isReady()) {
|
||||
PacketBody0Voice voice = new PacketBody0Voice(getRole().getOut());
|
||||
|
||||
voice.setCodecType(microphone.getCodec());
|
||||
voice.setCodecData(microphone.provide());
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.github.manevolent.ts3j;
|
||||
|
||||
import com.github.manevolent.ts3j.api.Client;
|
||||
import com.github.manevolent.ts3j.audio.Microphone;
|
||||
import com.github.manevolent.ts3j.enums.CodecType;
|
||||
import com.github.manevolent.ts3j.identity.LocalIdentity;
|
||||
import com.github.manevolent.ts3j.protocol.client.ClientConnectionState;
|
||||
import com.github.manevolent.ts3j.protocol.socket.client.LocalTeamspeakClientSocket;
|
||||
@@ -25,6 +27,24 @@ public class ServerConnectionTest {
|
||||
|
||||
LocalTeamspeakClientSocket client = new LocalTeamspeakClientSocket();
|
||||
|
||||
client.setMicrophone(new Microphone() {
|
||||
@Override
|
||||
public boolean isReady() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CodecType getCodec() {
|
||||
return CodecType.OPUS_MUSIC;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] provide() {
|
||||
System.err.println("Provide.");
|
||||
return new byte[0];
|
||||
}
|
||||
});
|
||||
|
||||
client.setIdentity(identity);
|
||||
|
||||
client.setNickname("Hello from Java");
|
||||
@@ -42,11 +62,7 @@ public class ServerConnectionTest {
|
||||
|
||||
assertEquals(client.getState(), ClientConnectionState.CONNECTED);
|
||||
|
||||
for (Client c : client.listClients()) {
|
||||
client.getClientInfo(c.getId());
|
||||
}
|
||||
|
||||
client.disconnect();
|
||||
client.setNickname("gjklsdfkjlgdsfgd2");
|
||||
|
||||
client.waitForState(ClientConnectionState.DISCONNECTED, 10000L);
|
||||
} catch (Throwable ex) {
|
||||
|
||||
Reference in New Issue
Block a user