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() { public void run() {
PacketBody0Voice voice = new PacketBody0Voice(getRole().getOut()); PacketBody0Voice voice = new PacketBody0Voice(getRole().getOut());
Microphone microphone; 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()) { if (!isConnected()) return;
// TODO
// Set a state and send a muted event
} else if (microphone.isReady()) {
voice.setCodecType(microphone.getCodec());
voice.setCodecData(microphone.provide());
try { // Attempt to get the current microphone instance, saving it in a variable to prevent
writePacket(voice); // any race conditions by accessing the parent class' this.microphone.
} catch (IOException e) { if ((microphone = LocalTeamspeakClientSocket.this.microphone) == null)
// All we are really concerned about here is a disconnection event, in which case the loop return;
// will exit.
} catch (TimeoutException e) { if (microphone.isMuted()) {
// Not really possible, as we might expect, voice doesn't have ACKs. // 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 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()) { for (Client c : client.listClients()) {
client.getClientInfo(c.getId()); client.getClientInfo(c.getId());