New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.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.0 to 1.2.1

2

package.json
{
"name": "ogg-opus-decoder",
"version": "1.2.0",
"version": "1.2.1",
"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.1 KiB minified bundle size
* 115.3 KiB minified bundle size
* Browser and NodeJS support
* Built in Web Worker support

@@ -6,0 +7,0 @@ * Based on [`libopusfile`](https://github.com/xiph/opusfile)

@@ -7,3 +7,3 @@ import OpusDecodedAudio from "./OpusDecodedAudio.js";

export default class OggOpusDecoder {
constructor() {
constructor(_OpusDecodedAudio, _EmscriptenWASM) {
// 120ms buffer recommended per http://opus-codec.org/docs/opusfile_api-0.7/group__stream__decoding.html

@@ -15,3 +15,5 @@ this._outSize = 120 * 48; // 120ms @ 48 khz.

this._ready = new Promise((resolve) => this._init().then(resolve));
this._ready = new Promise((resolve) =>
this._init(_OpusDecodedAudio, _EmscriptenWASM).then(resolve)
);
}

@@ -39,19 +41,22 @@

async _init() {
// injects dependencies when running as a web worker
async _init(_OpusDecodedAudio, _EmscriptenWASM) {
if (!this._api) {
let isMainThread;
const isWebWorker = _OpusDecodedAudio && _EmscriptenWASM;
try {
if (wasm || !wasm) isMainThread = true;
} catch {
isMainThread = false;
}
if (isWebWorker) {
// use classes injected into constructor parameters
this._OpusDecodedAudio = _OpusDecodedAudio;
this._EmscriptenWASM = _EmscriptenWASM;
if (isMainThread) {
// running as a webworker, use class level singleton for wasm compilation
this._api = new this._EmscriptenWASM();
} else {
// use classes from es6 imports
this._OpusDecodedAudio = OpusDecodedAudio;
this._EmscriptenWASM = EmscriptenWASM;
// use a global scope singleton so wasm compilation happens once only if class is instantiated
if (!wasm) wasm = new EmscriptenWASM();
if (!wasm) wasm = new this._EmscriptenWASM();
this._api = wasm;
} else {
// running as a webworker, use class level singleton for wasm compilation
this._api = new EmscriptenWASM();
}

@@ -165,3 +170,3 @@ }

return new OpusDecodedAudio(
return new this._OpusDecodedAudio(
[

@@ -168,0 +173,0 @@ OggOpusDecoder.concatFloat32(decodedLeft, decodedSamples),

@@ -11,8 +11,6 @@ import Worker from "web-worker";

"'use strict';" +
EmscriptenWASM.toString() +
OpusDecodedAudio.toString() +
OggOpusDecoder.toString() +
`(${(() => {
// dependencies need to be manually resolved when stringifying this function
`(${((_OggOpusDecoder, _OpusDecodedAudio, _EmscriptenWASM) => {
// We're in a Web Worker
const decoder = new OggOpusDecoder();
const decoder = new _OggOpusDecoder(_OpusDecodedAudio, _EmscriptenWASM);

@@ -61,3 +59,3 @@ self.onmessage = ({ data: { id, command, oggOpusData } }) => {

};
}).toString()})()`;
}).toString()})(${OggOpusDecoder}, ${OpusDecodedAudio}, ${EmscriptenWASM})`;

@@ -64,0 +62,0 @@ const type = "text/javascript";

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

Sorry, the diff of this file is not supported yet

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