Skip to content

Commit d1bce02

Browse files
Directly pass the packet buffer to the queue when it is direct
1 parent 2c19e28 commit d1bce02

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

api/src/main/java/com/sedmelluq/discord/lavaplayer/udpqueue/natives/UdpQueueManager.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,18 @@ public boolean queuePacket(long key, ByteBuffer packet, InetSocketAddress addres
6666
}
6767

6868
int length = packet.remaining();
69-
packetBuffer.clear();
70-
packetBuffer.put(packet);
69+
ByteBuffer directBuffer;
70+
if (packet.isDirect()) {
71+
directBuffer = packet;
72+
} else {
73+
packetBuffer.clear();
74+
packetBuffer.put(packet);
75+
directBuffer = packetBuffer;
76+
}
7177

7278
int port = address.getPort();
7379
String hostAddress = address.getAddress().getHostAddress();
74-
return library.queuePacket(instance, key, hostAddress, port, packetBuffer, length);
80+
return library.queuePacket(instance, key, hostAddress, port, directBuffer, length);
7581
}
7682
}
7783

0 commit comments

Comments
 (0)