Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ogg-opus-decoder

Package Overview
Dependencies
Maintainers
1
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ogg-opus-decoder - npm Package Compare versions

Comparing version 1.2.2 to 1.2.3

2

package.json
{
"name": "ogg-opus-decoder",
"version": "1.2.2",
"version": "1.2.3",
"description": "Web Assembly streaming Ogg Opus decoder",

@@ -5,0 +5,0 @@ "main": "dist/ogg-opus-decoder.min.js",

# `ogg-opus-decoder`
`ogg-opus-decoder` is a Web Assembly Ogg Opus audio decoder.
* 115.3 KiB minified bundle size
* 115.1 KiB minified bundle size
* Browser and NodeJS support

@@ -6,0 +6,0 @@ * Built in Web Worker support

@@ -33,5 +33,5 @@ import OpusDecodedAudio from "./OpusDecodedAudio.js";

// returns [pointer, array]
_getOutputArray(length) {
const pointer = this._api._malloc(Float32Array.BYTES_PER_ELEMENT * length);
const array = new Float32Array(this._api.HEAPF32.buffer, pointer, length);
_allocateTypedArray(length, TypedArray) {
const pointer = this._api._malloc(TypedArray.BYTES_PER_ELEMENT * length);
const array = new TypedArray(this._api.HEAP, pointer, length);
return [pointer, array];

@@ -67,7 +67,17 @@ }

this._inputPtr = this._api._malloc(this._inputArrSize);
// input data
[this._inputPtr, this._input] = this._allocateTypedArray(
this._inputArrSize,
Uint8Array
);
// output data
[this._leftPtr, this._leftArr] = this._getOutputArray(this._outSize);
[this._rightPtr, this._rightArr] = this._getOutputArray(this._outSize);
[this._leftPtr, this._leftArr] = this._allocateTypedArray(
this._outSize,
Float32Array
);
[this._rightPtr, this._rightArr] = this._allocateTypedArray(
this._outSize,
Float32Array
);
}

@@ -115,3 +125,3 @@

this._api.HEAPU8.set(dataToSend, this._inputPtr);
this._input.set(dataToSend);

@@ -127,3 +137,3 @@ // enqueue bytes to decode. Fail on error

throw Error(
"Could not enqueue bytes for decoding. You may also have invalid Ogg Opus file."
"Could not enqueue bytes for decoding. You may also have invalid Ogg Opus file."
);

@@ -130,0 +140,0 @@

@@ -11,54 +11,59 @@ import Worker from "web-worker";

constructor() {
const webworkerSourceCode =
"'use strict';" +
// dependencies need to be manually resolved when stringifying this function
`(${((_OggOpusDecoder, _OpusDecodedAudio, _EmscriptenWASM) => {
// We're in a Web Worker
const decoder = new _OggOpusDecoder(_OpusDecodedAudio, _EmscriptenWASM);
if (!sourceURL) {
const webworkerSourceCode =
"'use strict';" +
// dependencies need to be manually resolved when stringifying this function
`(${((_OggOpusDecoder, _OpusDecodedAudio, _EmscriptenWASM) => {
// We're in a Web Worker
const decoder = new _OggOpusDecoder(
_OpusDecodedAudio,
_EmscriptenWASM
);
self.onmessage = ({ data: { id, command, oggOpusData } }) => {
switch (command) {
case "ready":
decoder.ready.then(() => {
self.postMessage({
id,
self.onmessage = ({ data: { id, command, oggOpusData } }) => {
switch (command) {
case "ready":
decoder.ready.then(() => {
self.postMessage({
id,
});
});
});
break;
case "free":
decoder.free();
self.postMessage({
id,
});
break;
case "reset":
decoder.reset().then(() => {
break;
case "free":
decoder.free();
self.postMessage({
id,
});
});
break;
case "decode":
const { channelData, samplesDecoded, sampleRate } =
decoder.decode(new Uint8Array(oggOpusData));
break;
case "reset":
decoder.reset().then(() => {
self.postMessage({
id,
});
});
break;
case "decode":
const { channelData, samplesDecoded, sampleRate } =
decoder.decode(new Uint8Array(oggOpusData));
self.postMessage(
{
id,
channelData,
samplesDecoded,
sampleRate,
},
// The "transferList" parameter transfers ownership of channel data to main thread,
// which avoids copying memory.
channelData.map((channel) => channel.buffer)
);
break;
default:
this.console.error("Unknown command sent to worker: " + command);
}
};
}).toString()})(${OggOpusDecoder}, ${OpusDecodedAudio}, ${EmscriptenWASM})`;
self.postMessage(
{
id,
channelData,
samplesDecoded,
sampleRate,
},
// The "transferList" parameter transfers ownership of channel data to main thread,
// which avoids copying memory.
channelData.map((channel) => channel.buffer)
);
break;
default:
this.console.error(
"Unknown command sent to worker: " + command
);
}
};
}).toString()})(${OggOpusDecoder}, ${OpusDecodedAudio}, ${EmscriptenWASM})`;
if (!sourceURL) {
const type = "text/javascript";

@@ -65,0 +70,0 @@ try {

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc