Skip to content

Commit bfef07a

Browse files
committed
Fix ASIO module integration issues
- Add ASIO IPC handlers setup in main.js - Add ASIO cleanup in before-quit handler - Fix lib/index.js with graceful fallback when native module unavailable - Update CLAUDE.md Electron version references to v39.2.13-qp20
1 parent e04c564 commit bfef07a

File tree

3 files changed

+74
-18
lines changed

3 files changed

+74
-18
lines changed

CLAUDE.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ Quick reference:
6565
powershell.exe -NoProfile -ExecutionPolicy Bypass `
6666
-File C:\Users\Steve\code\electron\script\build_win_qp_release.ps1 `
6767
-WorkspaceRoot C:\electron-work-v36\src `
68-
-Tag v39.2.7 `
68+
-Tag v39.2.13 `
6969
-SkipSync
7070
```
7171

@@ -74,10 +74,10 @@ In `package.json`:
7474
```json
7575
{
7676
"build": {
77-
"electronVersion": "39.2.7-qp20",
77+
"electronVersion": "39.2.13-qp20",
7878
"electronDownload": {
7979
"mirror": "https://github.com/steveseguin/electron/releases/download/",
80-
"customDir": "v39.2.7-qp20"
80+
"customDir": "v39.2.13-qp20"
8181
}
8282
}
8383
}
@@ -169,7 +169,7 @@ npm start # Run in development mode
169169
| NVENC/HEVC | Yes | No | No |
170170
| Application Audio Capture | Yes | No | No |
171171
| Cursor Suppression | Yes | No | No |
172-
| Electron Version | 39.2.7-qp20 | 39.2.7 | 39.2.7 |
172+
| Electron Version | 39.2.13-qp20 | 39.2.7 | 39.2.7 |
173173

174174
### Environment Variables
175175
```bash
@@ -240,7 +240,7 @@ npm start -- --help
240240
### Windows Build Fails: "Cannot create symbolic link"
241241
Enable Developer Mode in Windows Settings, or run as Administrator.
242242

243-
### Linux Build Fails: "electron-v39.2.7-qp20-linux-x64.zip 404"
243+
### Linux Build Fails: "electron-v39.2.13-qp20-linux-x64.zip 404"
244244
The Linux build script should use stock Electron. Check `package.json` build:linux has the override flags.
245245

246246
### Native Module Not Found
@@ -253,7 +253,7 @@ git submodule update --init --recursive
253253
### Custom Electron Not Installing
254254
```bash
255255
# Check if custom version exists
256-
gh release view v39.2.7-qp20 --repo steveseguin/electron
256+
gh release view v39.2.13-qp20 --repo steveseguin/electron
257257

258258
# Force re-download
259259
rm -rf node_modules/electron/dist

main.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -815,6 +815,19 @@ try {
815815
console.error('Error loading window-audio-capture module:', err);
816816
}
817817

818+
// Load ASIO audio capture module (Windows only)
819+
let asioIpcHandlers = null;
820+
try {
821+
if (process.platform === 'win32') {
822+
console.log('Loading electron-asio module...');
823+
asioIpcHandlers = require('./native-modules/electron-asio/preload/ipc-handlers');
824+
asioIpcHandlers.setupAsioIpc(ipcMain);
825+
console.log('ASIO IPC handlers registered');
826+
}
827+
} catch (err) {
828+
console.warn('ASIO module not available:', err.message);
829+
}
830+
818831
var ver = app.getVersion();
819832
const DEFAULT_URL = `https://vdo.ninja/electron?version=${ver}`;
820833

@@ -4144,6 +4157,17 @@ var closing = 0;
41444157

41454158
app.on('before-quit', (event) => {
41464159
console.log("Application 'before-quit' event triggered.");
4160+
4161+
// Clean up ASIO streams
4162+
if (asioIpcHandlers && asioIpcHandlers.cleanupAsio) {
4163+
try {
4164+
asioIpcHandlers.cleanupAsio();
4165+
console.log('ASIO cleanup completed');
4166+
} catch (e) {
4167+
console.error('ASIO cleanup error:', e);
4168+
}
4169+
}
4170+
41474171
if (!BrowserWindow.getAllWindows().length) {
41484172
console.log("'before-quit': No windows open, quitting normally.");
41494173
return; // No need to preventDefault or delay if no windows.

native-modules/electron-asio/lib/index.js

Lines changed: 44 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,14 @@ const path = require('path');
88
const EventEmitter = require('events');
99

1010
// Load native addon
11-
let native;
11+
let native = null;
1212
try {
1313
native = require('../build/Release/electron_asio.node');
1414
} catch (e) {
1515
try {
1616
native = require('../build/Debug/electron_asio.node');
1717
} catch (e2) {
18-
throw new Error(
19-
'Failed to load electron-asio native module. ' +
20-
'Make sure you have built the addon with `npm run rebuild`. ' +
21-
'Original error: ' + e.message
22-
);
18+
console.warn('[electron-asio] Native module not available:', e.message);
2319
}
2420
}
2521

@@ -28,23 +24,39 @@ try {
2824
* @returns {boolean}
2925
*/
3026
function isAvailable() {
31-
return native.isAvailable();
27+
if (!native) return false;
28+
try {
29+
return native.isAvailable();
30+
} catch (e) {
31+
return false;
32+
}
3233
}
3334

3435
/**
3536
* Get version information
3637
* @returns {string}
3738
*/
3839
function getVersionInfo() {
39-
return native.getVersionInfo();
40+
if (!native) return 'ASIO module not loaded';
41+
try {
42+
return native.getVersionInfo();
43+
} catch (e) {
44+
return 'Unknown version';
45+
}
4046
}
4147

4248
/**
4349
* Get list of available ASIO devices
4450
* @returns {DeviceInfo[]}
4551
*/
4652
function getDevices() {
47-
return native.getDevices();
53+
if (!native) return [];
54+
try {
55+
return native.getDevices();
56+
} catch (e) {
57+
console.error('[electron-asio] Failed to get devices:', e);
58+
return [];
59+
}
4860
}
4961

5062
/**
@@ -53,7 +65,13 @@ function getDevices() {
5365
* @returns {DeviceInfo|null}
5466
*/
5567
function getDeviceInfo(deviceIndexOrName) {
56-
return native.getDeviceInfo(deviceIndexOrName);
68+
if (!native) return null;
69+
try {
70+
return native.getDeviceInfo(deviceIndexOrName);
71+
} catch (e) {
72+
console.error('[electron-asio] Failed to get device info:', e);
73+
return null;
74+
}
5775
}
5876

5977
/**
@@ -66,6 +84,9 @@ class AsioStream extends EventEmitter {
6684
*/
6785
constructor(config) {
6886
super();
87+
if (!native) {
88+
throw new Error('ASIO native module not available');
89+
}
6990
this._native = new native.AsioStream(config);
7091
this._config = config;
7192
this._processCallback = null;
@@ -218,14 +239,25 @@ function createStream(config) {
218239
* @returns {boolean}
219240
*/
220241
function initialize() {
221-
return native.initialize();
242+
if (!native) return false;
243+
try {
244+
return native.initialize();
245+
} catch (e) {
246+
console.error('[electron-asio] Initialize failed:', e);
247+
return false;
248+
}
222249
}
223250

224251
/**
225252
* Terminate the ASIO subsystem (call on app exit)
226253
*/
227254
function terminate() {
228-
native.terminate();
255+
if (!native) return;
256+
try {
257+
native.terminate();
258+
} catch (e) {
259+
console.warn('[electron-asio] Terminate error:', e);
260+
}
229261
}
230262

231263
// Export everything

0 commit comments

Comments
 (0)