A dynamic link library (DLL) initialization routine failed.
ComedicChimera opened this issue · comments
I am trying to use naudiodon to stream audio in an Electron.js application. When I attempt to use naudiodon, I get a series of errors related to a dll not being able to be initialized.
Here is my calling code:
const portAudio = require('naudiodon');
// get a list of devices
module.exports.getDeviceList = () => {
let deviceNames = {};
for(var x of portAudio.getDevices()) {
if (x.maxOutputChannels > 0) {
deviceNames[x] = x.id;
}
}
return deviceNames;
}
The code in my Electron.js html page:
let deviceList = Object.keys(api.getDeviceList());
let optionsHtml = '';
for(var x of deviceList) {
optionsHtml += `<option>${x}</option>`;
}
$('#device').html(optionsHtml);
With api being a reference to the first bit of code.
The traceback:
Error: A dynamic link library (DLL) initialization routine failed.
\\?\C:\--\node_modules\naudiodon\build\Release\naudiodon.node
at process.module.(anonymous function) [as dlopen] (ELECTRON_ASAR.js:172:20)
at Object.Module._extensions..node (module.js:598:18)
at Object.module.(anonymous function) [as .node] (ELECTRON_ASAR.js:172:20)
at Module.load (module.js:503:32)
at tryModuleLoad (module.js:466:12)
at Function.Module._load (module.js:458:3)
at Module.require (module.js:513:17)
at require (internal/module.js:11:18)
at bindings (C:\--\node_modules\bindings\bindings.js:81:44)
at Object.<anonymous>
(C:\--\node_modules\naudiodon\index.js:19:46)
at process.module.(anonymous function) [as dlopen] (ELECTRON_ASAR.js:172:20)
at Object.Module._extensions..node (module.js:598:18)
at Object.module.(anonymous function) [as .node] (ELECTRON_ASAR.js:172:20)
at Module.load (module.js:503:32)
at tryModuleLoad (module.js:466:12)
at Function.Module._load (module.js:458:3)
at Module.require (module.js:513:17)
at require (internal/module.js:11:18)
at bindings (C:\--\node_modules\bindings\bindings.js:81:44)
at Object.<anonymous> (C:\--\node_modules\naudiodon\index.js:19:46)
at Object.exception
...
Part following the ellipsis appear to be irrelevant. (the error echoing up through my code)
I installed naudiodon with npm install naudiodon --save
.
I am using the following version of npm and nodejs:
Nodejs: v8.10.0
npm: v5.6.0
And the module (naudiodon) version is: 0.4.6
I am on Windows 10 (64 bit OS)
Please reply as soon as possible. Thanks!
There are two dlls associated with naudiodon that will need to be loaded - naudiodon.node (a dll really) and portaudio_x64.dll. You are 'require'ing one which will try to pull in the other. It isn't clear to me from your log whether one or both is not being found. Just a couple of thoughts:
-
Have you tried your JS code without electron ?
-
Depending on your configuration, electron has a bundle step that may need some configuration to be told to build naudiodon correctly and include the portaudio binary. A quick search yielded: https://electronjs.org/docs/tutorial/application-packaging & https://stackoverflow.com/questions/38361996/how-can-i-bundle-a-precompiled-binary-with-electron
Good luck!
I had this issue with this as well as some other packages. Installing native modules fixed it for me
npm install --save-dev electron-rebuild
# Every time you run "npm install", run this
./node_modules/.bin/electron-rebuild
# On Windows if you have trouble, try:
.\node_modules\.bin\electron-rebuild.cmd
Closing this issue.