mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2025-01-10 17:11:56 +01:00
Fossil: Attempt to fix opus decoding
This commit is contained in:
parent
02b704b0ba
commit
c16c4d7515
@ -400,21 +400,16 @@ public class FossilHRWatchAdapter extends FossilWatchAdapter implements VoiceHel
|
|||||||
final int CHANNELS = 1;
|
final int CHANNELS = 1;
|
||||||
final int MAX_FRAME_SIZE = 6 * 960;
|
final int MAX_FRAME_SIZE = 6 * 960;
|
||||||
|
|
||||||
final ByteBuffer buf = ByteBuffer.wrap(characteristic.getValue());
|
byte[] frame = characteristic.getValue();
|
||||||
|
|
||||||
final byte[] frame = new byte[960];
|
|
||||||
|
|
||||||
while (buf.position() < buf.limit()) {
|
|
||||||
buf.get(frame);
|
|
||||||
try {
|
|
||||||
final byte[] pcm = new byte[MAX_FRAME_SIZE * CHANNELS * 2];
|
final byte[] pcm = new byte[MAX_FRAME_SIZE * CHANNELS * 2];
|
||||||
int ret = opusCodec.decode(frame, frame.length, pcm, MAX_FRAME_SIZE, 0);
|
int ret = 0;
|
||||||
|
try {
|
||||||
|
ret = opusCodec.decode(frame, frame.length, pcm, MAX_FRAME_SIZE, 0);
|
||||||
|
} catch (RemoteException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
LOG.debug("Opus decode: {}", ret);
|
LOG.debug("Opus decode: {}", ret);
|
||||||
audio.write(pcm, 0, ret * 2 /* 16 bit */);
|
audio.write(pcm, 0, ret * 2 /* 16 bit */);
|
||||||
} catch (final Exception e) {
|
|
||||||
LOG.error("Failed to process opus frame", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user