Trey
08/17/2023, 8:35 PMTrey
08/17/2023, 8:36 PMpublic external expect fun opus_decode(
st: kotlinx.cinterop.CValuesRef<cnames.structs.OpusDecoder>?,
data: kotlinx.cinterop.CValuesRef<kotlinx.cinterop.UByteVar /* = kotlinx.cinterop.UByteVarOf<kotlin.UByte> */>?,
len: cocoapods.OpusKit.opus_int32 /* = <http://kotlin.Int|kotlin.Int> */,
pcm: kotlinx.cinterop.CValuesRef<cocoapods.OpusKit.opus_int16Var /* = kotlinx.cinterop.ShortVarOf<cocoapods.OpusKit.opus_int16 /* = kotlin.Short */> */>?,
frame_size: <http://kotlin.Int|kotlin.Int>, decode_fec: <http://kotlin.Int|kotlin.Int>): <http://kotlin.Int|kotlin.Int> { /* compiled code */ }
Trey
08/17/2023, 10:13 PMTrey
08/17/2023, 10:13 PMval outputLen = _framesize * _channels * opus_int16.SIZE_BYTES
var opusOutData = allocArray<opus_int16Var>(outputLen)
val result = opus_decode(
st = it.pointed.ptr,
data = uByteArray.toCValues(),
len = uByteArray.size,
pcm = opusOutData,
frame_size = _framesize,
decode_fec = 0
)
if (result < OPUS_OK) {
logErrorCode(result)
} else {
val array = (0 until outputLen).map { opusOutData.get(it)}.toTypedArray()
return array.toShortArray()
}