@mingxy/ocosay 1.1.7 → 1.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/backends/index.js +7 -3
- package/dist/core/backends/naudiodon-backend.js +8 -0
- package/dist/package.json +1 -1
- package/dist/plugin.js +6428 -6335
- package/package.json +1 -1
- package/scripts/install-portaudio.cjs +131 -76
|
@@ -75,11 +75,15 @@ export function createBackend(type = BackendType.AUTO, options = {}) {
|
|
|
75
75
|
try {
|
|
76
76
|
const naudiodon = require('naudiodon');
|
|
77
77
|
if (naudiodon) {
|
|
78
|
-
|
|
78
|
+
const devices = naudiodon.getDevices();
|
|
79
|
+
if (devices && devices.length > 0) {
|
|
80
|
+
return new NaudiodonBackend(options);
|
|
81
|
+
}
|
|
82
|
+
logger.debug('naudiodon has no audio devices, skipping');
|
|
79
83
|
}
|
|
80
84
|
}
|
|
81
85
|
catch (err) {
|
|
82
|
-
logger.
|
|
86
|
+
logger.error({ err }, 'failed to initialize naudiodon backend');
|
|
83
87
|
}
|
|
84
88
|
}
|
|
85
89
|
switch (platform) {
|
|
@@ -93,7 +97,7 @@ export function createBackend(type = BackendType.AUTO, options = {}) {
|
|
|
93
97
|
case 'win32':
|
|
94
98
|
return new PowerShellBackend(options);
|
|
95
99
|
default:
|
|
96
|
-
|
|
100
|
+
return new HowlerBackend(options);
|
|
97
101
|
}
|
|
98
102
|
}
|
|
99
103
|
function createBackendByType(type, options) {
|
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
* - v1: new naudiodon({sampleRate, channels, bitDepth})
|
|
7
7
|
* - v2: AudioIO({outOptions: {sampleRate, channelCount, sampleFormat}})
|
|
8
8
|
*/
|
|
9
|
+
import { createModuleLogger } from '../../utils/logger';
|
|
10
|
+
const logger = createModuleLogger('NaudiodonBackend');
|
|
9
11
|
class UnsupportedError extends Error {
|
|
10
12
|
constructor(message) {
|
|
11
13
|
super(message);
|
|
@@ -35,6 +37,7 @@ export class NaudiodonBackend {
|
|
|
35
37
|
return;
|
|
36
38
|
try {
|
|
37
39
|
const naudiodon = require('naudiodon');
|
|
40
|
+
logger.debug('naudiodon loaded, creating AudioIO stream');
|
|
38
41
|
this.audioStream = naudiodon.AudioIO({
|
|
39
42
|
outOptions: {
|
|
40
43
|
sampleRate: this.sampleRate,
|
|
@@ -42,15 +45,20 @@ export class NaudiodonBackend {
|
|
|
42
45
|
sampleFormat: 16
|
|
43
46
|
}
|
|
44
47
|
});
|
|
48
|
+
logger.debug('AudioIO stream created');
|
|
45
49
|
this.audioStream.on('error', (error) => {
|
|
50
|
+
logger.error({ error }, 'AudioIO stream error');
|
|
46
51
|
this.handleError(error);
|
|
47
52
|
});
|
|
53
|
+
logger.debug('calling audioStream.start()');
|
|
48
54
|
this.audioStream.start();
|
|
55
|
+
logger.info('naudiodon backend started successfully');
|
|
49
56
|
this._started = true;
|
|
50
57
|
this._stopped = false;
|
|
51
58
|
this.events?.onStart?.();
|
|
52
59
|
}
|
|
53
60
|
catch (error) {
|
|
61
|
+
logger.error({ error }, 'naudiodon start failed');
|
|
54
62
|
if (error.code === 'MODULE_NOT_FOUND') {
|
|
55
63
|
throw new Error('naudiodon is not installed. Run: npm install naudiodon');
|
|
56
64
|
}
|