Microphone changes

This commit is contained in:
Manevolent
2018-08-05 01:24:10 -04:00
parent 836a952a6d
commit 68dcaa35c3
2 changed files with 23 additions and 21 deletions
@@ -330,27 +330,29 @@ public class LocalTeamspeakClientSocket
public void run() {
PacketBody0Voice voice = new PacketBody0Voice(getRole().getOut());
Microphone microphone;
while (isConnected()) {
// 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)
continue;
if (microphone.isMuted()) {
// TODO
// Set a state and send a muted event
} else if (microphone.isReady()) {
voice.setCodecType(microphone.getCodec());
voice.setCodecData(microphone.provide());
if (!isConnected()) return;
try {
writePacket(voice);
} catch (IOException e) {
// All we are really concerned about here is a disconnection event, in which case the loop
// will exit.
} catch (TimeoutException e) {
// Not really possible, as we might expect, voice doesn't have ACKs.
}
// 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)
return;
if (microphone.isMuted()) {
// TODO
// Set a state and send a muted event
} else if (microphone.isReady()) {
voice.setClientId(getClientId()); // not necessary probably
voice.setCodecType(microphone.getCodec());
voice.setCodecData(microphone.provide());
try {
writePacket(voice);
} catch (IOException e) {
// All we are really concerned about here is a disconnection event, in which case the loop
// will exit.
} catch (TimeoutException e) {
// Not really possible; as we might expect, voice doesn't have ACKs.
}
}
}
@@ -38,9 +38,9 @@ public class ServerConnectionTest {
10000L
);
client.sendServerMessage("\u26D4");
client.sendServerMessage("\u26D4 You are not listening to this channel.");
assertEquals(client.getState(), ClientConnectionState.CONNECTED);
assertEquals(client.getState(), ClientConnectionState.CONNECTED);
for (Client c : client.listClients()) {
client.getClientInfo(c.getId());