mirror of
https://github.com/legop3/MultiRoombaRover.git
synced 2026-09-16 09:31:20 -04:00
gwah
This commit is contained in:
@@ -450,6 +450,9 @@ function decodeMicChunk(payload = {}) {
|
||||
if (Buffer.isBuffer(binary)) {
|
||||
return binary;
|
||||
}
|
||||
if (binary && typeof binary === 'object' && binary.type === 'Buffer' && Array.isArray(binary.data)) {
|
||||
return Buffer.from(binary.data);
|
||||
}
|
||||
if (binary instanceof Uint8Array) {
|
||||
return Buffer.from(binary.buffer, binary.byteOffset, binary.byteLength);
|
||||
}
|
||||
@@ -474,6 +477,9 @@ function pushMicChunk(roverId, ownerSocketId, payload = {}) {
|
||||
if (!bytes.length) {
|
||||
throw new Error('Mic chunk missing');
|
||||
}
|
||||
if (bytes.length % 2 !== 0) {
|
||||
throw new Error('Mic chunk has invalid PCM byte length');
|
||||
}
|
||||
if (bytes.length > 64 * 1024) {
|
||||
throw new Error('Mic chunk too large');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user