From d412213f0cfea32c292a093947b249c8829c2e11 Mon Sep 17 00:00:00 2001 From: WolverinDEV Date: Fri, 2 Mar 2018 17:36:35 +0100 Subject: [PATCH] Some fixes --- .idea/workspace.xml | 48 +++++++++++++++++++++++-------------------- js/codec/Codec.js | 7 +++++++ js/codec/Codec.js.map | 2 +- js/codec/Codec.ts | 9 ++++++++ 4 files changed, 43 insertions(+), 23 deletions(-) diff --git a/.idea/workspace.xml b/.idea/workspace.xml index d21168bb..05276d26 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -1,7 +1,11 @@ - + + + + + - @@ -216,12 +220,12 @@ - @@ -346,14 +350,6 @@ - - - - - - - - @@ -364,8 +360,16 @@ - - + + + + + + + + + + diff --git a/js/codec/Codec.js b/js/codec/Codec.js index e3d326eb..cc1200fa 100644 --- a/js/codec/Codec.js +++ b/js/codec/Codec.js @@ -32,6 +32,13 @@ class OpusCodec extends Codec { return buf; } encode(data) { + this.encoderBufferLength = this.encoderSamplesPerChannel * this.config.numberOfChannels; + this.encoderBufferPointer = this._malloc(this.encoderBufferLength * 4); // 4 bytes per sample + this.encoderBuffer = this.HEAPF32.subarray(this.encoderBufferPointer >> 2, (this.encoderBufferPointer >> 2) + this.encoderBufferLength); + this.encoderOutputMaxLength = 4000; + this.encoderOutputPointer = this._malloc(this.encoderOutputMaxLength); + this.encoderOutputBuffer = this.HEAPU8.subarray(this.encoderOutputPointer, this.encoderOutputPointer + this.encoderOutputMaxLength); + Module.HEAP8.subarray(2, 3, 4); let maxBytes = 4096 * 1 + 4; let buffer = Module._malloc(maxBytes); console.log("X"); diff --git a/js/codec/Codec.js.map b/js/codec/Codec.js.map index ab5b9cf8..16570d8d 100644 --- a/js/codec/Codec.js.map +++ b/js/codec/Codec.js.map @@ -1 +1 @@ -{"version":3,"file":"Codec.js","sourceRoot":"","sources":["Codec.ts"],"names":[],"mappings":"AAAA;IACI,gBAAc,CAAC;CASlB;AAED,eAAgB,SAAQ,KAAK;IAQzB;QACI,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EAAE,SAAS,CAAC,UAAU,GAAG,MAAM,CAAC,CAAC;QAClF,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QACrB,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAChC,CAAC;IAEO,YAAY,CAAC,UAAe;QAChC,IAAI,QAAQ,GAAG,UAAU,CAAC,MAAM,GAAG,UAAU,CAAC,iBAAiB,CAAC;QAChE,IAAI,GAAG,GAAG,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QACnC,IAAI,SAAS,GAAG,IAAI,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,EAAE,QAAQ,CAAC,CAAC;QACpE,SAAS,CAAC,GAAG,CAAC,IAAI,UAAU,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC;QACjD,MAAM,CAAC,SAAS,CAAC;IACrB,CAAC;CACJ"} \ No newline at end of file diff --git a/js/codec/Codec.ts b/js/codec/Codec.ts index 04a5ef09..a27f6153 100644 --- a/js/codec/Codec.ts +++ b/js/codec/Codec.ts @@ -54,6 +54,15 @@ class OpusCodec extends Codec { } encode(data: Float32Array): Uint8Array | string { + this.encoderBufferLength = this.encoderSamplesPerChannel * this.config.numberOfChannels; + this.encoderBufferPointer = this._malloc( this.encoderBufferLength * 4 ); // 4 bytes per sample + this.encoderBuffer = this.HEAPF32.subarray( this.encoderBufferPointer >> 2, (this.encoderBufferPointer >> 2) + this.encoderBufferLength ); + + this.encoderOutputMaxLength = 4000; + this.encoderOutputPointer = this._malloc( this.encoderOutputMaxLength ); + this.encoderOutputBuffer = this.HEAPU8.subarray( this.encoderOutputPointer, this.encoderOutputPointer + this.encoderOutputMaxLength ); + + Module.HEAP8.subarray(2, 3, 4); let maxBytes = 4096 * 1 + 4; let buffer = Module._malloc(maxBytes); console.log("X");