Skip to content

Commit

Permalink
Optimizations
Browse files Browse the repository at this point in the history
  • Loading branch information
sh123 committed Dec 9, 2023
1 parent 4b8321e commit 49f8060
Showing 1 changed file with 2 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,17 +80,14 @@ public void sendTextMessage(TextMessage textMessage) throws IOException {
@Override
public void sendPcmAudio(String src, String dst, short[] pcmFrame) throws IOException {
_parentProtocolCallback.onTransmitPcmAudio(src, dst, pcmFrame);
Log.v(TAG, DebugTools.shortsToHex(pcmFrame));
int encodedBytesCnt = Opus.encode(_opusCon, pcmFrame, _pcmFrameSize, _recordAudioEncodedBuffer);
if (encodedBytesCnt == 0) {
Log.w(TAG, "Nothing was encoded");
return;
}
if (encodedBytesCnt > 0) {
byte[] frame = new byte[encodedBytesCnt];
for (int i = 0; i < encodedBytesCnt; i++) {
frame[i] = (byte) _recordAudioEncodedBuffer[i];
}
System.arraycopy(_recordAudioEncodedBuffer, 0, frame, 0, encodedBytesCnt);
Log.v(TAG, "pcm count: " + pcmFrame.length + ", encoded bytes count: " + encodedBytesCnt);
_childProtocol.sendCompressedAudio(src, dst, frame);
} else {
Expand Down Expand Up @@ -130,8 +127,7 @@ protected void onReceiveCompressedAudio(String src, String dst, byte[] audioEnco
}
short [] decodedSamples = new short[decodedSamplesCnt];
if (decodedSamplesCnt > 0) {
System.arraycopy(_playbackAudioBuffer, 0, decodedSamples, 0, decodedSamplesCnt);
Log.v(TAG, DebugTools.shortsToHex(decodedSamples));
System.arraycopy(_playbackAudioBuffer, 0, decodedSamples, 0, decodedSamplesCnt)
} else {
Log.e(TAG, "Decode error: " + decodedSamplesCnt);
_parentProtocolCallback.onProtocolRxError();
Expand Down

0 comments on commit 49f8060

Please sign in to comment.