Skip to content

Commit 61725ee

Browse files
committed
fix: improve error handling & other minor fixes
1 parent 12f4186 commit 61725ee

File tree

4 files changed

+29
-22
lines changed

4 files changed

+29
-22
lines changed

jsconfig.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"paths": {
88
"@/*": ["src/*"]
99
},
10-
"lib": ["esnext", "dom", "dom.iterable", "scripthost"]
10+
"lib": ["esnext", "dom", "dom.iterable", "scripthost"],
11+
"types": []
1112
}
1213
}

src/components/pages/DevicesPage.vue

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<tbody>
2121
<tr v-for="device in searchDevices" :key="device">
2222
<td>
23-
<span v-if="editDevice != device">{{
23+
<span v-if="editDevice != device" class="copy">{{
2424
persistentData.devices[device].name
2525
}}</span>
2626
<input
@@ -33,7 +33,7 @@
3333
<td>{{ device }}</td>
3434
<td>{{ persistentData.devices[device].count }}</td>
3535
<td>
36-
<span v-if="editDevice != device">{{
36+
<span v-if="editDevice != device" class="copy">{{
3737
persistentData.devices[device].description
3838
}}</span>
3939
<input

src/components/pages/StreamsPage.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
</td>
7171
<td>{{ stream.origin.address }}</td>
7272
<td>
73-
<span v-if="stream.isSupported">
73+
<span v-if="stream.isSupported" class="copy">
7474
{{ stream.codec }} / {{ stream.samplerate }}Hz /
7575
{{ stream.channels }}
7676
</span>

src/lib/audio.js

+24-18
Original file line numberDiff line numberDiff line change
@@ -18,24 +18,26 @@ const start = function (args) {
1818

1919
client = dgram.createSocket({ type: "udp4", reuseAddr: true });
2020

21-
//other constants
21+
// Error handling
22+
client.on("error", (err) => {
23+
console.error(`Socket error: ${err.stack}`);
24+
});
25+
26+
client.on("listening", function () {
27+
client.addMembership(args.mcast, args.networkInterface);
28+
});
29+
30+
// Constants
2231
const bufferSize = 1024;
2332
const jitterBufferSize = args.jitterBufferEnabled ? args.jitterBufferSize : 0;
24-
25-
//set up constants for lates use
2633
const samplesPerPacket = Math.round((args.samplerate / 1000) * args.ptime);
2734
const bytesPerSample = args.codec == "L24" ? 3 : 2;
2835
const pcmDataSize = samplesPerPacket * bytesPerSample * args.channels;
2936
const packetSize = pcmDataSize + 12;
3037
const pcmL16out = Buffer.alloc(samplesPerPacket * 4 * bufferSize);
3138

32-
//vars
3339
let seqInternal = -1;
3440

35-
client.on("listening", function () {
36-
client.addMembership(args.mcast, args.networkInterface);
37-
});
38-
3941
client.on("message", function (buffer, remote) {
4042
if (buffer.length != packetSize || remote.address != args.addr) {
4143
return;
@@ -79,7 +81,7 @@ const start = function (args) {
7981
rtAudio = new RtAudio(args.audioAPI);
8082
let devices = rtAudio.getDevices();
8183
let id;
82-
var found = false;
84+
let found = false;
8385
let defaultOutputDevice;
8486

8587
for (let i = 0; i < devices.length; i++) {
@@ -104,15 +106,19 @@ const start = function (args) {
104106
id = defaultOutputDevice.id;
105107
}
106108

107-
rtAudio.openStream(
108-
{ deviceId: id, nChannels: 2, firstChannel: 0 },
109-
null,
110-
RtAudioFormat.RTAUDIO_SINT16,
111-
args.samplerate,
112-
samplesPerPacket,
113-
"AES67 Monitor"
114-
);
115-
rtAudio.start();
109+
try {
110+
rtAudio.openStream(
111+
{ deviceId: id, nChannels: 2, firstChannel: 0 },
112+
null,
113+
RtAudioFormat.RTAUDIO_SINT16,
114+
args.samplerate,
115+
samplesPerPacket,
116+
"AES67 Monitor"
117+
);
118+
rtAudio.start();
119+
} catch (error) {
120+
console.error("Error during stream setup:", error);
121+
}
116122

117123
client.bind(5004);
118124
streamOpen = true;

0 commit comments

Comments
 (0)