fix el 20 worker
This commit is contained in:
parent
67094c5e41
commit
b1d1ad1653
2 changed files with 8 additions and 6 deletions
|
@ -333,7 +333,7 @@ export class BrowserWindow {
|
||||||
contextIsolation: false,
|
contextIsolation: false,
|
||||||
webviewTag: true,
|
webviewTag: true,
|
||||||
plugins: true,
|
plugins: true,
|
||||||
nodeIntegrationInWorker: false,
|
nodeIntegrationInWorker: true,
|
||||||
webSecurity: false,
|
webSecurity: false,
|
||||||
preload: join(utils.getPath("srcPath"), "./preload/cider-preload.js"),
|
preload: join(utils.getPath("srcPath"), "./preload/cider-preload.js"),
|
||||||
},
|
},
|
||||||
|
|
|
@ -34,7 +34,9 @@ export default class RAOP {
|
||||||
private worker: any = null;
|
private worker: any = null;
|
||||||
|
|
||||||
private processNode = `
|
private processNode = `
|
||||||
import {parentPort, workerData} from "worker_threads";
|
const {
|
||||||
|
Worker, isMainThread, parentPort, workerData
|
||||||
|
} = require('node:worker_threads');
|
||||||
function getAudioConv (buffers) {
|
function getAudioConv (buffers) {
|
||||||
|
|
||||||
function interleave16(leftChannel, rightChannel) {
|
function interleave16(leftChannel, rightChannel) {
|
||||||
|
@ -264,10 +266,10 @@ export default class RAOP {
|
||||||
if (this.airtunes != null) {
|
if (this.airtunes != null) {
|
||||||
if (this.worker == null) {
|
if (this.worker == null) {
|
||||||
try {
|
try {
|
||||||
const toDataUrl = (js: any) => new URL(`data:text/javascript,${encodeURIComponent(js)}`);
|
// const toDataUrl = (js: any) => new URL(`data:text/javascript,${encodeURIComponent(js)}`);
|
||||||
// let blob = new Blob([this.processNode], { type: 'application/javascript' });
|
// let blob = new Blob([this.processNode], { type: 'application/javascript' });
|
||||||
//Create new worker
|
//Create new worker
|
||||||
this.worker = new Worker(toDataUrl(this.processNode));
|
this.worker = new Worker(this.processNode, { eval: true });
|
||||||
|
|
||||||
//Listen for a message from worker
|
//Listen for a message from worker
|
||||||
this.worker.on("message", (result: any) => {
|
this.worker.on("message", (result: any) => {
|
||||||
|
@ -279,7 +281,7 @@ export default class RAOP {
|
||||||
});
|
});
|
||||||
|
|
||||||
this.worker.on("error", (error: any) => {
|
this.worker.on("error", (error: any) => {
|
||||||
console.log("bruh", error);
|
console.log("worker err", error);
|
||||||
});
|
});
|
||||||
this.worker.postMessage({ buffer: [leftbuffer, rightbuffer] });
|
this.worker.postMessage({ buffer: [leftbuffer, rightbuffer] });
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue