@ciphore/radiocli 0.2.3 → 0.2.5
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/CHANGELOG.md +147 -2
- package/CONTRIBUTING.md +46 -6
- package/README.md +108 -209
- package/SECURITY.md +23 -1
- package/dist/agent/alarm-service.js +10 -7
- package/dist/agent/cli.js +16 -1
- package/dist/agent/command-schema.js +47 -0
- package/dist/agent/headless-host.js +234 -67
- package/dist/agent/launcher.js +7 -67
- package/dist/agent/mcp-install.js +15 -15
- package/dist/agent/mcp-server.js +10 -5
- package/dist/agent/service.js +74 -39
- package/dist/agent/session.js +227 -53
- package/dist/agent/tui-session.js +213 -0
- package/dist/alarms/active-session.js +9 -12
- package/dist/alarms/cli.js +19 -3
- package/dist/alarms/guard.js +79 -36
- package/dist/alarms/inhibitor.js +27 -22
- package/dist/alarms/occurrence-cache.js +25 -0
- package/dist/alarms/power-guard-store.js +2 -10
- package/dist/alarms/runner.js +140 -45
- package/dist/alarms/schedule.js +37 -2
- package/dist/alarms/scheduler.js +202 -52
- package/dist/alarms/setup-verification.js +1 -2
- package/dist/alarms/system-volume-linux.js +160 -0
- package/dist/alarms/system-volume-ownership.js +335 -0
- package/dist/alarms/system-volume.js +188 -26
- package/dist/alarms/terminal-launcher.js +76 -136
- package/dist/alarms/tui-presence.js +2 -4
- package/dist/cli/arguments.js +212 -0
- package/dist/cli/completion.js +44 -0
- package/dist/cli/doctor.js +156 -0
- package/dist/cli/interactive.js +79 -0
- package/dist/cli/listener.js +227 -0
- package/dist/cli/output.js +121 -0
- package/dist/cli/render-tui.js +34 -0
- package/dist/cli.js +198 -154
- package/dist/platform/capabilities.js +60 -0
- package/dist/platform/desktop-media.js +61 -0
- package/dist/platform/desktop.js +36 -0
- package/dist/platform/diagnostics.js +273 -0
- package/dist/{player/command.js → platform/executables.js} +43 -9
- package/dist/platform/ipc.js +14 -0
- package/dist/platform/json-worker.js +111 -0
- package/dist/platform/launch-command.js +138 -0
- package/dist/platform/loopback.js +44 -0
- package/dist/platform/mpris.js +356 -0
- package/dist/platform/network.js +380 -0
- package/dist/platform/omarchy.js +147 -0
- package/dist/platform/packages.js +222 -0
- package/dist/platform/paths.js +40 -0
- package/dist/platform/runtime.js +67 -0
- package/dist/platform/shell.js +24 -0
- package/dist/platform/storage.js +48 -0
- package/dist/platform/support.js +214 -0
- package/dist/platform/terminal.js +63 -0
- package/dist/platform/terminals.js +223 -0
- package/dist/player/airplay-discovery.js +145 -60
- package/dist/player/airplay-policy.js +15 -0
- package/dist/player/airplay-process.js +63 -0
- package/dist/player/airplay-readiness.js +42 -0
- package/dist/player/airplay-sender-health.js +49 -49
- package/dist/player/airplay-sender-package.js +5 -0
- package/dist/player/airplay-sender-patch.js +102 -4
- package/dist/player/airplay-setup.js +51 -0
- package/dist/player/airplay-worker.js +97 -41
- package/dist/player/backend-install.js +17 -95
- package/dist/player/command-diagnostics.js +2 -2
- package/dist/player/ffmpeg-input.js +37 -0
- package/dist/player/mpv-desktop-media.js +194 -0
- package/dist/player/mpv-ipc-client.js +52 -2
- package/dist/player/player-controller.js +569 -82
- package/dist/player/radio-engine.js +282 -0
- package/dist/playlists/playlist.js +18 -16
- package/dist/providers/cache.js +293 -99
- package/dist/providers/discovery-session.js +111 -0
- package/dist/providers/provider-manager.js +106 -28
- package/dist/providers/radio-browser.js +418 -89
- package/dist/providers/radio-garden.js +18 -23
- package/dist/setup-playback.js +152 -0
- package/dist/setup.js +163 -168
- package/dist/storage/file-lock.js +113 -0
- package/dist/storage/read-settings.js +33 -0
- package/dist/storage/replace-file.js +20 -0
- package/dist/storage/repository.js +247 -0
- package/dist/storage/station-identity.js +21 -0
- package/dist/storage/station-schema.js +27 -0
- package/dist/storage/store.js +333 -107
- package/dist/streams/import-stream.js +163 -0
- package/dist/ui/AdaptiveContent.js +49 -32
- package/dist/ui/App.js +822 -481
- package/dist/ui/AppContent.js +5 -5
- package/dist/ui/airplay-settings.js +12 -5
- package/dist/ui/app-state.js +8 -1
- package/dist/ui/ascii.js +11 -2
- package/dist/ui/bidi-ranges.js +45 -0
- package/dist/ui/components/AdaptiveMarquee.js +20 -10
- package/dist/ui/components/Logo.js +5 -2
- package/dist/ui/components/Menu.js +2 -2
- package/dist/ui/components/ScreenHeader.js +1 -1
- package/dist/ui/components/StationList.js +6 -4
- package/dist/ui/components/TopTabs.js +1 -1
- package/dist/ui/display-context.js +8 -11
- package/dist/ui/format.js +37 -4
- package/dist/ui/help-content.js +9 -6
- package/dist/ui/layout.js +5 -2
- package/dist/ui/page-footer.js +3 -3
- package/dist/ui/rtl-output.js +137 -0
- package/dist/ui/screen-items.js +12 -6
- package/dist/ui/screen-meta.js +1 -1
- package/dist/ui/screens/AirPlayCodeScreen.js +6 -2
- package/dist/ui/screens/AirPlaySettingsScreen.js +10 -6
- package/dist/ui/screens/AlarmsScreen.js +5 -2
- package/dist/ui/screens/ExploreScreen.js +2 -1
- package/dist/ui/screens/HelpScreen.js +8 -4
- package/dist/ui/screens/HomeScreen.js +5 -1
- package/dist/ui/screens/MapScreen.js +1 -1
- package/dist/ui/screens/NowPlayingScreen.js +4 -4
- package/dist/ui/screens/SearchScreen.js +3 -1
- package/dist/ui/screens/SettingsScreen.js +28 -21
- package/dist/ui/screens/StatsScreen.js +3 -1
- package/dist/ui/system-actions.js +80 -52
- package/dist/ui/terminal-renderer.js +16 -0
- package/dist/ui/text-direction.js +9 -0
- package/dist/ui/use-alarm-tui.js +57 -42
- package/dist/ui/use-app-input.js +84 -30
- package/dist/ui/use-command-executor.js +50 -19
- package/dist/ui/visualizers/gallop.js +1 -1
- package/dist/ui/visualizers/receiver-style-registry.js +2 -1
- package/dist/update-check.js +10 -18
- package/docs/THIRD_PARTY_NOTICES.md +6 -4
- package/package.json +34 -11
- package/scripts/build-airplay-native.mjs +22 -0
- package/vendor/node-airtunes2/LICENSE +208 -0
- package/vendor/node-airtunes2/RADIOCLI_PATCH.md +29 -0
- package/vendor/node-airtunes2/README.md +225 -0
- package/vendor/node-airtunes2/UPSTREAM.json +50 -0
- package/vendor/node-airtunes2/binding.gyp +41 -0
- package/vendor/node-airtunes2/lib/ap2_test.js +4 -0
- package/vendor/node-airtunes2/lib/atv.js +307 -0
- package/vendor/node-airtunes2/lib/atvAuthenticator.js +136 -0
- package/vendor/node-airtunes2/lib/audio_out.js +69 -0
- package/vendor/node-airtunes2/lib/circular_buffer.js +133 -0
- package/vendor/node-airtunes2/lib/config.js +26 -0
- package/vendor/node-airtunes2/lib/device_airtunes.js +532 -0
- package/vendor/node-airtunes2/lib/devices.js +266 -0
- package/vendor/node-airtunes2/lib/ed25519.js +26 -0
- package/vendor/node-airtunes2/lib/homekit/credentials.js +86 -0
- package/vendor/node-airtunes2/lib/homekit/encryption.js +69 -0
- package/vendor/node-airtunes2/lib/homekit/number.js +44 -0
- package/vendor/node-airtunes2/lib/homekit/tlv.js +95 -0
- package/vendor/node-airtunes2/lib/http.js +189 -0
- package/vendor/node-airtunes2/lib/index.d.ts +141 -0
- package/vendor/node-airtunes2/lib/index.js +127 -0
- package/vendor/node-airtunes2/lib/ntp.js +37 -0
- package/vendor/node-airtunes2/lib/num_util.js +21 -0
- package/vendor/node-airtunes2/lib/packet_pool.js +43 -0
- package/vendor/node-airtunes2/lib/rtsp.js +1807 -0
- package/vendor/node-airtunes2/lib/srp.js +158 -0
- package/vendor/node-airtunes2/lib/udp_servers.js +214 -0
- package/vendor/node-airtunes2/lib/util.js +12 -0
- package/vendor/node-airtunes2/package.json +31 -0
- package/vendor/node-airtunes2/src/CADebugMacros.h +257 -0
- package/vendor/node-airtunes2/src/CAHostTimeBase.cpp +105 -0
- package/vendor/node-airtunes2/src/CAHostTimeBase.h +224 -0
- package/vendor/node-airtunes2/src/aes_utils.c +864 -0
- package/vendor/node-airtunes2/src/aes_utils.h +24 -0
- package/vendor/node-airtunes2/src/base64.c +136 -0
- package/vendor/node-airtunes2/src/base64.h +42 -0
- package/vendor/node-airtunes2/src/bindings.cc +29 -0
- package/vendor/node-airtunes2/src/codec.cc +170 -0
- package/vendor/node-airtunes2/src/coreaudio.cc +332 -0
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
const bigInt = require('big-integer')
|
|
2
|
+
const sha1 = require('js-sha1')
|
|
3
|
+
const memoize = require('lodash/memoize')
|
|
4
|
+
const { hexString2ArrayBuffer } = require('./util')
|
|
5
|
+
|
|
6
|
+
// ...
|
|
7
|
+
|
|
8
|
+
const groups = {
|
|
9
|
+
1024: {
|
|
10
|
+
N: new bigInt(
|
|
11
|
+
'EEAF0AB9ADB38DD69C33F80AFA8FC5E86072618775FF3C0B9EA2314C'
|
|
12
|
+
+ '9C256576D674DF7496EA81D3383B4813D692C6E0E0D5D8E250B98BE4'
|
|
13
|
+
+ '8E495C1D6089DAD15DC7D7B46154D6B6CE8EF4AD69B15D4982559B29'
|
|
14
|
+
+ '7BCF1885C529F566660E57EC68EDBC3C05726CC02FD4CBF4976EAA9A'
|
|
15
|
+
+ 'FD5138FE8376435B9FC61D2FC0EB06E3', 16),
|
|
16
|
+
|
|
17
|
+
g: new bigInt(2),
|
|
18
|
+
},
|
|
19
|
+
|
|
20
|
+
2048: {
|
|
21
|
+
N: new bigInt(
|
|
22
|
+
'AC6BDB41324A9A9BF166DE5E1389582FAF72B6651987EE07FC319294'
|
|
23
|
+
+ '3DB56050A37329CBB4A099ED8193E0757767A13DD52312AB4B03310D'
|
|
24
|
+
+ 'CD7F48A9DA04FD50E8083969EDB767B0CF6095179A163AB3661A05FB'
|
|
25
|
+
+ 'D5FAAAE82918A9962F0B93B855F97993EC975EEAA80D740ADBF4FF74'
|
|
26
|
+
+ '7359D041D5C33EA71D281E446B14773BCA97B43A23FB801676BD207A'
|
|
27
|
+
+ '436C6481F1D2B9078717461A5B9D32E688F87748544523B524B0D57D'
|
|
28
|
+
+ '5EA77A2775D2ECFA032CFBDBF52FB3786160279004E57AE6AF874E73'
|
|
29
|
+
+ '03CE53299CCC041C7BC308D82A5698F3A8D0C38271AE35F8E9DBFBB6'
|
|
30
|
+
+ '94B5C803D89F7AE435DE236D525F54759B65E372FCD68EF20FA7111F'
|
|
31
|
+
+ '9E4AFF73', 16),
|
|
32
|
+
|
|
33
|
+
g: new bigInt(2),
|
|
34
|
+
},
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// ...
|
|
38
|
+
|
|
39
|
+
class SRP {
|
|
40
|
+
constructor(group) {
|
|
41
|
+
this.group = group
|
|
42
|
+
|
|
43
|
+
this.N = groups[group].N
|
|
44
|
+
this.g = groups[group].g
|
|
45
|
+
|
|
46
|
+
this.A = memoize(this.A)
|
|
47
|
+
this.K = memoize(this.K)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// ...
|
|
51
|
+
// Private.
|
|
52
|
+
|
|
53
|
+
u(A, B) {
|
|
54
|
+
const A_buf = hexString2ArrayBuffer(A)
|
|
55
|
+
const B_buf = hexString2ArrayBuffer(B)
|
|
56
|
+
|
|
57
|
+
const result = new Uint8Array(A_buf.byteLength + B_buf.byteLength)
|
|
58
|
+
result.set(A_buf)
|
|
59
|
+
result.set(B_buf, A_buf.byteLength)
|
|
60
|
+
|
|
61
|
+
return sha1(result)
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
k() {
|
|
65
|
+
const padded_g = '0'.repeat((this.group / 4) - 1) + this.g.toString(16)
|
|
66
|
+
|
|
67
|
+
const N_buf = hexString2ArrayBuffer(this.N.toString(16))
|
|
68
|
+
const g_buf = hexString2ArrayBuffer(padded_g)
|
|
69
|
+
|
|
70
|
+
const result = new Uint8Array(N_buf.byteLength + g_buf.byteLength)
|
|
71
|
+
result.set(N_buf)
|
|
72
|
+
result.set(g_buf, N_buf.byteLength)
|
|
73
|
+
|
|
74
|
+
return sha1(result)
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
x(I, P, s) {
|
|
78
|
+
const s_buf = hexString2ArrayBuffer(s.toLowerCase())
|
|
79
|
+
const I_P_buf = hexString2ArrayBuffer(sha1(I + ':' + P))
|
|
80
|
+
|
|
81
|
+
const result = new Uint8Array(s_buf.byteLength + I_P_buf.byteLength)
|
|
82
|
+
result.set(s_buf)
|
|
83
|
+
result.set(I_P_buf, s_buf.byteLength)
|
|
84
|
+
|
|
85
|
+
return sha1(result)
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
S(B, k, x, a, u) {
|
|
89
|
+
B = new bigInt(B, 16)
|
|
90
|
+
k = new bigInt(k, 16)
|
|
91
|
+
x = new bigInt(x, 16)
|
|
92
|
+
a = new bigInt(a, 16)
|
|
93
|
+
u = new bigInt(u, 16)
|
|
94
|
+
|
|
95
|
+
return B.add(this.N.multiply(k)).subtract(this.g.modPow(x, this.N).multiply(k)).mod(this.N)
|
|
96
|
+
.modPow(a.add(u.multiply(x)), this.N)
|
|
97
|
+
.toString(16)
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// ...
|
|
101
|
+
// Public.
|
|
102
|
+
|
|
103
|
+
A(a) {
|
|
104
|
+
return this.g.modPow(new bigInt(a, 16), this.N).toString(16)
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
K(I, P, s, a, B) {
|
|
108
|
+
const k = this.k()
|
|
109
|
+
const x = this.x(I, P, s)
|
|
110
|
+
const u = this.u(this.A(a), B)
|
|
111
|
+
const S = this.S(B, k, x, a, u)
|
|
112
|
+
|
|
113
|
+
// ...
|
|
114
|
+
|
|
115
|
+
const S_buf = hexString2ArrayBuffer(S)
|
|
116
|
+
|
|
117
|
+
let hash1 = new Uint8Array(S_buf.byteLength + 4)
|
|
118
|
+
hash1.set(S_buf)
|
|
119
|
+
hash1.set([0x00, 0x00, 0x00, 0x00], S_buf.byteLength)
|
|
120
|
+
|
|
121
|
+
let hash2 = new Uint8Array(S_buf.byteLength + 4)
|
|
122
|
+
hash2.set(S_buf)
|
|
123
|
+
hash2.set([0x00, 0x00, 0x00, 0x01], S_buf.byteLength)
|
|
124
|
+
|
|
125
|
+
return sha1(hash1) + sha1(hash2)
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
M1(I, P, s, a, B) {
|
|
129
|
+
// M1 = H( H(N) ^ H(g) | H(I) | s | PAD(A) | PAD(B) | K )
|
|
130
|
+
const A = this.A(a)
|
|
131
|
+
const K = this.K(I, P, s, a, B)
|
|
132
|
+
|
|
133
|
+
const hN = new Uint8Array(sha1.arrayBuffer(hexString2ArrayBuffer(this.N.toString(16))))
|
|
134
|
+
const hg = new Uint8Array(sha1.arrayBuffer([this.g.toString(16)]))
|
|
135
|
+
|
|
136
|
+
const hN_hg = new Uint8Array(20)
|
|
137
|
+
for (let i = 0; i < 20; i++) {
|
|
138
|
+
hN_hg[i] = hN[i] ^ hg[i]
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
const hI = sha1.arrayBuffer(I)
|
|
142
|
+
|
|
143
|
+
// ...
|
|
144
|
+
|
|
145
|
+
return sha1.create()
|
|
146
|
+
.update(hN_hg)
|
|
147
|
+
.update(hI)
|
|
148
|
+
.update(hexString2ArrayBuffer(s))
|
|
149
|
+
.update(hexString2ArrayBuffer(A))
|
|
150
|
+
.update(hexString2ArrayBuffer(B))
|
|
151
|
+
.update(hexString2ArrayBuffer(K))
|
|
152
|
+
.hex()
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// ...
|
|
157
|
+
|
|
158
|
+
module.exports = SRP
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
const dgram = require('dgram')
|
|
2
|
+
const events = require('events')
|
|
3
|
+
const util = require('util')
|
|
4
|
+
const async = require('async')
|
|
5
|
+
const config = require('./config')
|
|
6
|
+
const nu = require('./num_util')
|
|
7
|
+
const ntp = require('./ntp')
|
|
8
|
+
|
|
9
|
+
const UNBOUND = 0
|
|
10
|
+
const BINDING = 1
|
|
11
|
+
const BOUND = 2
|
|
12
|
+
|
|
13
|
+
function UDPServers() {
|
|
14
|
+
events.EventEmitter.call(this)
|
|
15
|
+
|
|
16
|
+
this.status = UNBOUND
|
|
17
|
+
|
|
18
|
+
this.control = {
|
|
19
|
+
socket: null,
|
|
20
|
+
port: null,
|
|
21
|
+
name: 'control',
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
this.timing = {
|
|
25
|
+
socket: null,
|
|
26
|
+
port: null,
|
|
27
|
+
name: 'timing',
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
this.hosts = []
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
util.inherits(UDPServers, events.EventEmitter)
|
|
34
|
+
|
|
35
|
+
UDPServers.prototype.bind = function (host) {
|
|
36
|
+
let self = this
|
|
37
|
+
|
|
38
|
+
this.hosts.push(host)
|
|
39
|
+
|
|
40
|
+
switch (this.status) {
|
|
41
|
+
case BOUND:
|
|
42
|
+
process.nextTick(function () {
|
|
43
|
+
self.emit('ports', null, this.control, this.timing)
|
|
44
|
+
})
|
|
45
|
+
return
|
|
46
|
+
|
|
47
|
+
case BINDING:
|
|
48
|
+
return
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
self = this
|
|
52
|
+
this.status = BINDING
|
|
53
|
+
|
|
54
|
+
// Timing socket
|
|
55
|
+
this.timing.socket = dgram.createSocket({ type: 'udp4', reuseAddr: true })
|
|
56
|
+
|
|
57
|
+
this.timing.socket.on('message', function (msg, rinfo) {
|
|
58
|
+
// only listen and respond on own hosts
|
|
59
|
+
if (self.hosts.indexOf(rinfo.address) < 0) return
|
|
60
|
+
|
|
61
|
+
var ts1 = msg.readUInt32BE(24)
|
|
62
|
+
var ts2 = msg.readUInt32BE(28)
|
|
63
|
+
|
|
64
|
+
var reply = new Buffer(32)
|
|
65
|
+
reply.writeUInt16BE(0x80d3, 0)
|
|
66
|
+
reply.writeUInt16BE(0x0007, 2)
|
|
67
|
+
reply.writeUInt32BE(0x00000000, 4)
|
|
68
|
+
|
|
69
|
+
reply.writeUInt32BE(ts1, 8)
|
|
70
|
+
reply.writeUInt32BE(ts2, 12)
|
|
71
|
+
|
|
72
|
+
var ntpTime = ntp.timestamp()
|
|
73
|
+
|
|
74
|
+
ntpTime.copy(reply, 16)
|
|
75
|
+
ntpTime.copy(reply, 24)
|
|
76
|
+
|
|
77
|
+
self.timing.socket.send(
|
|
78
|
+
reply, 0, reply.length,
|
|
79
|
+
rinfo.port, rinfo.address,
|
|
80
|
+
)
|
|
81
|
+
})
|
|
82
|
+
|
|
83
|
+
// Control socket
|
|
84
|
+
this.control.socket = dgram.createSocket({ type: 'udp4', reuseAddr: true })
|
|
85
|
+
|
|
86
|
+
this.control.socket.on('message', function (msg, rinfo) {
|
|
87
|
+
// only listen for own hosts
|
|
88
|
+
if (self.hosts.indexOf(rinfo.address) < 0) return
|
|
89
|
+
|
|
90
|
+
var resendRequested = msg.readUInt8(1) == (0x80 | 0x55)
|
|
91
|
+
// var serverSeq = msg.readUInt16BE(2);
|
|
92
|
+
if (resendRequested) {
|
|
93
|
+
const missedSeq = msg.readUInt16BE(4)
|
|
94
|
+
const count = msg.readUInt16BE(6)
|
|
95
|
+
self.emit('resendRequested', missedSeq, count)
|
|
96
|
+
}
|
|
97
|
+
})
|
|
98
|
+
|
|
99
|
+
// // Event socket
|
|
100
|
+
// this.event.socket = dgram.createSocket('udp4');
|
|
101
|
+
|
|
102
|
+
// this.event.socket.on('message', function(msg, rinfo) {
|
|
103
|
+
|
|
104
|
+
// // only listen and respond on own hosts
|
|
105
|
+
// if (self.hosts.indexOf(rinfo.address) < 0) return;
|
|
106
|
+
// });
|
|
107
|
+
|
|
108
|
+
// Find open ports
|
|
109
|
+
if (!(process.platform == 'darwin')) {
|
|
110
|
+
var current_port = config.udp_default_port
|
|
111
|
+
|
|
112
|
+
self.control.socket.bind(function (err) {
|
|
113
|
+
if (err) {
|
|
114
|
+
return cb(err)
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
self.control.port = self.control.socket.address().port
|
|
118
|
+
})
|
|
119
|
+
self.timing.socket.bind(function (err) {
|
|
120
|
+
if (err) {
|
|
121
|
+
return cb(err)
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
self.timing.port = self.timing.socket.address().port
|
|
125
|
+
})
|
|
126
|
+
let myInterval = setInterval(small, 100)
|
|
127
|
+
function small() {
|
|
128
|
+
if (self.timing.port != null && self.control.port != null) {
|
|
129
|
+
clearInterval(myInterval)
|
|
130
|
+
self.status = BOUND
|
|
131
|
+
self.emit('ports', null, self.control, self.timing)
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
var to_bind = [this.control, this.timing]
|
|
137
|
+
var current_port = config.udp_default_port
|
|
138
|
+
async.whilst(
|
|
139
|
+
function (cb) { cb(null, to_bind.length > 0) },
|
|
140
|
+
function (cb) {
|
|
141
|
+
var nextPort = to_bind[0]
|
|
142
|
+
nextPort.socket.once('error', function (e) {
|
|
143
|
+
if (e.code === 'EADDRINUSE') {
|
|
144
|
+
// try next port
|
|
145
|
+
current_port++
|
|
146
|
+
cb()
|
|
147
|
+
}
|
|
148
|
+
else
|
|
149
|
+
// otherwise, report the error and cancel everything
|
|
150
|
+
cb(e)
|
|
151
|
+
})
|
|
152
|
+
|
|
153
|
+
nextPort.socket.once('listening', function () {
|
|
154
|
+
// socket successfully bound
|
|
155
|
+
to_bind.shift()
|
|
156
|
+
nextPort.port = current_port
|
|
157
|
+
current_port++
|
|
158
|
+
cb()
|
|
159
|
+
})
|
|
160
|
+
|
|
161
|
+
nextPort.socket.bind(current_port)
|
|
162
|
+
},
|
|
163
|
+
function (err) {
|
|
164
|
+
if (err) {
|
|
165
|
+
self.close()
|
|
166
|
+
self.emit('ports', err)
|
|
167
|
+
}
|
|
168
|
+
else {
|
|
169
|
+
self.status = BOUND
|
|
170
|
+
self.emit('ports', null, self.control, self.timing)
|
|
171
|
+
}
|
|
172
|
+
},
|
|
173
|
+
)
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
UDPServers.prototype.close = function () {
|
|
178
|
+
//
|
|
179
|
+
try {
|
|
180
|
+
this.status = UNBOUND
|
|
181
|
+
|
|
182
|
+
this.timing.socket.close()
|
|
183
|
+
this.timing.socket = null
|
|
184
|
+
|
|
185
|
+
this.control.socket.close()
|
|
186
|
+
this.control.socket = null
|
|
187
|
+
}
|
|
188
|
+
catch (e) { }
|
|
189
|
+
|
|
190
|
+
// this.event.socket.close();
|
|
191
|
+
// this.event.socket = null;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
UDPServers.prototype.sendControlSync = function (seq, dev) {
|
|
195
|
+
if (this.status !== BOUND)
|
|
196
|
+
return
|
|
197
|
+
|
|
198
|
+
var packet = new Buffer(20)
|
|
199
|
+
|
|
200
|
+
packet.writeUInt16BE(0x80d4, 0)
|
|
201
|
+
packet.writeUInt16BE(0x0007, 2)
|
|
202
|
+
packet.writeUInt32BE(nu.low32(seq * config.frames_per_packet), 4)
|
|
203
|
+
|
|
204
|
+
var ntpTime = ntp.timestamp()
|
|
205
|
+
ntpTime.copy(packet, 8)
|
|
206
|
+
|
|
207
|
+
packet.writeUInt32BE(
|
|
208
|
+
nu.low32(seq * config.frames_per_packet
|
|
209
|
+
+ config.sampling_rate * 2), 16,
|
|
210
|
+
)
|
|
211
|
+
this.control.socket.send(packet, 0, packet.length, dev.controlPort, dev.host)
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
module.exports = UDPServers
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
const hexString2ArrayBuffer
|
|
2
|
+
= hexString => new Uint8Array(hexString.match(/[\da-f]{2}/gi).map(h => parseInt(h, 16)))
|
|
3
|
+
|
|
4
|
+
const buf2hex
|
|
5
|
+
= buffer => Array.prototype.map.call(new Uint8Array(buffer), x => ('00' + x.toString(16)).slice(-2)).join('')
|
|
6
|
+
|
|
7
|
+
// ...
|
|
8
|
+
|
|
9
|
+
module.exports = {
|
|
10
|
+
hexString2ArrayBuffer,
|
|
11
|
+
buf2hex,
|
|
12
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "node-airtunes2",
|
|
3
|
+
"version": "2.5.0-radiocli.1",
|
|
4
|
+
"private": true,
|
|
5
|
+
"description": "an AirTunes v2 implementation: stream wirelessly to audio devices.",
|
|
6
|
+
"main": "./lib/index.js",
|
|
7
|
+
"licenses": [
|
|
8
|
+
{
|
|
9
|
+
"type": "AGPLv3"
|
|
10
|
+
}
|
|
11
|
+
],
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "git+https://github.com/bertrandda/node-airtunes2.git"
|
|
15
|
+
},
|
|
16
|
+
"radiocliLegacyPairing": "node:crypto",
|
|
17
|
+
"dependencies": {
|
|
18
|
+
"@noble/ed25519": "1.7.5",
|
|
19
|
+
"async": "3.2.6",
|
|
20
|
+
"axlsign": "git+https://github.com/ciderapp/curve25519-js.git#cae68782564b83ffa1c7c757e40a3944cb140290",
|
|
21
|
+
"big-integer": "1.6.52",
|
|
22
|
+
"bplist-creator": "0.1.1",
|
|
23
|
+
"bplist-parser": "0.3.2",
|
|
24
|
+
"chacha-js": "git+https://github.com/ciderapp/chacha20poly1305.git#f85941b8f5c62843a1459758cc3dbabad9f849cb",
|
|
25
|
+
"curve25519-js": "0.0.4",
|
|
26
|
+
"fast-srp-hap": "2.0.4",
|
|
27
|
+
"js-sha1": "0.7.0",
|
|
28
|
+
"lodash": "4.18.1",
|
|
29
|
+
"python-struct": "1.1.3"
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
/* Copyright: � Copyright 2004 Apple Computer, Inc. All rights reserved.
|
|
2
|
+
|
|
3
|
+
Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc.
|
|
4
|
+
("Apple") in consideration of your agreement to the following terms, and your
|
|
5
|
+
use, installation, modification or redistribution of this Apple software
|
|
6
|
+
constitutes acceptance of these terms. If you do not agree with these terms,
|
|
7
|
+
please do not use, install, modify or redistribute this Apple software.
|
|
8
|
+
|
|
9
|
+
In consideration of your agreement to abide by the following terms, and subject
|
|
10
|
+
to these terms, Apple grants you a personal, non-exclusive license, under Apple�s
|
|
11
|
+
copyrights in this original Apple software (the "Apple Software"), to use,
|
|
12
|
+
reproduce, modify and redistribute the Apple Software, with or without
|
|
13
|
+
modifications, in source and/or binary forms; provided that if you redistribute
|
|
14
|
+
the Apple Software in its entirety and without modifications, you must retain
|
|
15
|
+
this notice and the following text and disclaimers in all such redistributions of
|
|
16
|
+
the Apple Software. Neither the name, trademarks, service marks or logos of
|
|
17
|
+
Apple Computer, Inc. may be used to endorse or promote products derived from the
|
|
18
|
+
Apple Software without specific prior written permission from Apple. Except as
|
|
19
|
+
expressly stated in this notice, no other rights or licenses, express or implied,
|
|
20
|
+
are granted by Apple herein, including but not limited to any patent rights that
|
|
21
|
+
may be infringed by your derivative works or by other works in which the Apple
|
|
22
|
+
Software may be incorporated.
|
|
23
|
+
|
|
24
|
+
The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO
|
|
25
|
+
WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED
|
|
26
|
+
WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
27
|
+
PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN
|
|
28
|
+
COMBINATION WITH YOUR PRODUCTS.
|
|
29
|
+
|
|
30
|
+
IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR
|
|
31
|
+
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
|
32
|
+
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
33
|
+
ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION
|
|
34
|
+
OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT
|
|
35
|
+
(INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN
|
|
36
|
+
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
37
|
+
*/
|
|
38
|
+
/*=============================================================================
|
|
39
|
+
CADebugMacros.h
|
|
40
|
+
|
|
41
|
+
=============================================================================*/
|
|
42
|
+
#if !defined(__CADebugMacros_h__)
|
|
43
|
+
#define __CADebugMacros_h__
|
|
44
|
+
|
|
45
|
+
//=============================================================================
|
|
46
|
+
// CADebugMacros
|
|
47
|
+
//=============================================================================
|
|
48
|
+
|
|
49
|
+
//#define CoreAudio_StopOnFailure 1
|
|
50
|
+
//#define CoreAudio_TimeStampMessages 1
|
|
51
|
+
//#define CoreAudio_ThreadStampMessages 1
|
|
52
|
+
//#define CoreAudio_FlushDebugMessages 1
|
|
53
|
+
|
|
54
|
+
#define CA4CCToCString(the4CC) { ((char*)&the4CC)[0], ((char*)&the4CC)[1], ((char*)&the4CC)[2], ((char*)&the4CC)[3], 0 }
|
|
55
|
+
|
|
56
|
+
#if DEBUG || CoreAudio_Debug
|
|
57
|
+
|
|
58
|
+
// can be used to break into debugger immediately, also see CADebugger
|
|
59
|
+
#define BusError() (*(long *)0 = 0)
|
|
60
|
+
|
|
61
|
+
// basic debugging print routines
|
|
62
|
+
#if TARGET_OS_MAC && !TARGET_API_MAC_CARBON
|
|
63
|
+
extern pascal void DebugStr(const unsigned char* debuggerMsg);
|
|
64
|
+
#define DebugMessage(msg) DebugStr("\p"msg)
|
|
65
|
+
#define DebugMessageN1(msg, N1)
|
|
66
|
+
#define DebugMessageN2(msg, N1, N2)
|
|
67
|
+
#define DebugMessageN3(msg, N1, N2, N3)
|
|
68
|
+
#else
|
|
69
|
+
#include "CADebugPrintf.h"
|
|
70
|
+
|
|
71
|
+
#if CoreAudio_FlushDebugMessages && !CoreAudio_UseSysLog
|
|
72
|
+
#define FlushRtn ;fflush(DebugPrintfFile)
|
|
73
|
+
#else
|
|
74
|
+
#define FlushRtn
|
|
75
|
+
#endif
|
|
76
|
+
|
|
77
|
+
#if CoreAudio_ThreadStampMessages
|
|
78
|
+
#include <pthread.h>
|
|
79
|
+
#include "CAHostTimeBase.h"
|
|
80
|
+
#define DebugMessage(msg) DebugPrintfRtn(DebugPrintfFile, "%p %.4f: %s\n", pthread_self(), ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), msg) FlushRtn
|
|
81
|
+
#define DebugMessageN1(msg, N1) DebugPrintfRtn(DebugPrintfFile, "%p %.4f: "msg"\n", pthread_self(), ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), N1) FlushRtn
|
|
82
|
+
#define DebugMessageN2(msg, N1, N2) DebugPrintfRtn(DebugPrintfFile, "%p %.4f: "msg"\n", pthread_self(), ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), N1, N2) FlushRtn
|
|
83
|
+
#define DebugMessageN3(msg, N1, N2, N3) DebugPrintfRtn(DebugPrintfFile, "%p %.4f: "msg"\n", pthread_self(), ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), N1, N2, N3) FlushRtn
|
|
84
|
+
#define DebugMessageN4(msg, N1, N2, N3, N4) DebugPrintfRtn(DebugPrintfFile, "%p %.4f: "msg"\n", pthread_self(), ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), N1, N2, N3, N4) FlushRtn
|
|
85
|
+
#define DebugMessageN5(msg, N1, N2, N3, N4, N5) DebugPrintfRtn(DebugPrintfFile, "%p %.4f: "msg"\n", pthread_self(), ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), N1, N2, N3, N4, N5) FlushRtn
|
|
86
|
+
#define DebugMessageN6(msg, N1, N2, N3, N4, N5, N6) DebugPrintfRtn(DebugPrintfFile, "%p %.4f: "msg"\n", pthread_self(), ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), N1, N2, N3, N4, N5, N6) FlushRtn
|
|
87
|
+
#define DebugMessageN7(msg, N1, N2, N3, N4, N5, N6, N7) DebugPrintfRtn(DebugPrintfFile, "%p %.4f: "msg"\n", pthread_self(), ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), N1, N2, N3, N4, N5, N6, N7) FlushRtn
|
|
88
|
+
#define DebugMessageN8(msg, N1, N2, N3, N4, N5, N6, N7, N8) DebugPrintfRtn(DebugPrintfFile, "%p %.4f: "msg"\n", pthread_self(), ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), N1, N2, N3, N4, N5, N6, N7, N8) FlushRtn
|
|
89
|
+
#define DebugMessageN9(msg, N1, N2, N3, N4, N5, N6, N7, N8, N9) DebugPrintfRtn(DebugPrintfFile, "%p %.4f: "msg"\n", pthread_self(), ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), N1, N2, N3, N4, N5, N6, N7, N8, N9) FlushRtn
|
|
90
|
+
#elif CoreAudio_TimeStampMessages
|
|
91
|
+
#include "CAHostTimeBase.h"
|
|
92
|
+
#define DebugMessage(msg) DebugPrintfRtn(DebugPrintfFile, "%.4f: %s\n", pthread_self(), ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), msg) FlushRtn
|
|
93
|
+
#define DebugMessageN1(msg, N1) DebugPrintfRtn(DebugPrintfFile, "%.4f: "msg"\n", ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), N1) FlushRtn
|
|
94
|
+
#define DebugMessageN2(msg, N1, N2) DebugPrintfRtn(DebugPrintfFile, "%.4f: "msg"\n", ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), N1, N2) FlushRtn
|
|
95
|
+
#define DebugMessageN3(msg, N1, N2, N3) DebugPrintfRtn(DebugPrintfFile, "%.4f: "msg"\n", ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), N1, N2, N3) FlushRtn
|
|
96
|
+
#define DebugMessageN4(msg, N1, N2, N3, N4) DebugPrintfRtn(DebugPrintfFile, "%.4f: "msg"\n", ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), N1, N2, N3, N4) FlushRtn
|
|
97
|
+
#define DebugMessageN5(msg, N1, N2, N3, N4, N5) DebugPrintfRtn(DebugPrintfFile, "%.4f: "msg"\n", ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), N1, N2, N3, N4, N5) FlushRtn
|
|
98
|
+
#define DebugMessageN6(msg, N1, N2, N3, N4, N5, N6) DebugPrintfRtn(DebugPrintfFile, "%.4f: "msg"\n", ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), N1, N2, N3, N4, N5, N6) FlushRtn
|
|
99
|
+
#define DebugMessageN7(msg, N1, N2, N3, N4, N5, N6, N7) DebugPrintfRtn(DebugPrintfFile, "%.4f: "msg"\n", ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), N1, N2, N3, N4, N5, N6, N7) FlushRtn
|
|
100
|
+
#define DebugMessageN8(msg, N1, N2, N3, N4, N5, N6, N7, N8) DebugPrintfRtn(DebugPrintfFile, "%.4f: "msg"\n", ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), N1, N2, N3, N4, N5, N6, N7, N8) FlushRtn
|
|
101
|
+
#define DebugMessageN9(msg, N1, N2, N3, N4, N5, N6, N7, N8, N9) DebugPrintfRtn(DebugPrintfFile, "%.4f: "msg"\n", ((Float64)(CAHostTimeBase::GetCurrentTimeInNanos()) / 1000000.0), N1, N2, N3, N4, N5, N6, N7, N8, N9) FlushRtn
|
|
102
|
+
#else
|
|
103
|
+
#define DebugMessage(msg) DebugPrintfRtn(DebugPrintfFile, "%s\n", msg) FlushRtn
|
|
104
|
+
#define DebugMessageN1(msg, N1) DebugPrintfRtn(DebugPrintfFile, msg"\n", N1) FlushRtn
|
|
105
|
+
#define DebugMessageN2(msg, N1, N2) DebugPrintfRtn(DebugPrintfFile, msg"\n", N1, N2) FlushRtn
|
|
106
|
+
#define DebugMessageN3(msg, N1, N2, N3) DebugPrintfRtn(DebugPrintfFile, msg"\n", N1, N2, N3) FlushRtn
|
|
107
|
+
#define DebugMessageN4(msg, N1, N2, N3, N4) DebugPrintfRtn(DebugPrintfFile, msg"\n", N1, N2, N3, N4) FlushRtn
|
|
108
|
+
#define DebugMessageN5(msg, N1, N2, N3, N4, N5) DebugPrintfRtn(DebugPrintfFile, msg"\n", N1, N2, N3, N4, N5) FlushRtn
|
|
109
|
+
#define DebugMessageN6(msg, N1, N2, N3, N4, N5, N6) DebugPrintfRtn(DebugPrintfFile, msg"\n", N1, N2, N3, N4, N5, N6) FlushRtn
|
|
110
|
+
#define DebugMessageN7(msg, N1, N2, N3, N4, N5, N6, N7) DebugPrintfRtn(DebugPrintfFile, msg"\n", N1, N2, N3, N4, N5, N6, N7) FlushRtn
|
|
111
|
+
#define DebugMessageN8(msg, N1, N2, N3, N4, N5, N6, N7, N8) DebugPrintfRtn(DebugPrintfFile, msg"\n", N1, N2, N3, N4, N5, N6, N7, N8) FlushRtn
|
|
112
|
+
#define DebugMessageN9(msg, N1, N2, N3, N4, N5, N6, N7, N8, N9) DebugPrintfRtn(DebugPrintfFile, msg"\n", N1, N2, N3, N4, N5, N6, N7, N8, N9) FlushRtn
|
|
113
|
+
#endif
|
|
114
|
+
#endif
|
|
115
|
+
void DebugPrint(const char *fmt, ...); // can be used like printf
|
|
116
|
+
#define DEBUGPRINT(msg) DebugPrint msg // have to double-parenthesize arglist (see Debugging.h)
|
|
117
|
+
#if VERBOSE
|
|
118
|
+
#define vprint(msg) DEBUGPRINT(msg)
|
|
119
|
+
#else
|
|
120
|
+
#define vprint(msg)
|
|
121
|
+
#endif
|
|
122
|
+
|
|
123
|
+
#if CoreAudio_StopOnFailure
|
|
124
|
+
#include "CADebugger.h"
|
|
125
|
+
#define STOP CADebuggerStop()
|
|
126
|
+
#else
|
|
127
|
+
#define STOP
|
|
128
|
+
#endif
|
|
129
|
+
|
|
130
|
+
#else
|
|
131
|
+
#define DebugMessage(msg)
|
|
132
|
+
#define DebugMessageN1(msg, N1)
|
|
133
|
+
#define DebugMessageN2(msg, N1, N2)
|
|
134
|
+
#define DebugMessageN3(msg, N1, N2, N3)
|
|
135
|
+
#define DebugMessageN4(msg, N1, N2, N3, N4)
|
|
136
|
+
#define DebugMessageN5(msg, N1, N2, N3, N4, N5)
|
|
137
|
+
#define DebugMessageN6(msg, N1, N2, N3, N4, N5, N6)
|
|
138
|
+
#define DebugMessageN7(msg, N1, N2, N3, N4, N5, N6, N7)
|
|
139
|
+
#define DebugMessageN8(msg, N1, N2, N3, N4, N5, N6, N7, N8)
|
|
140
|
+
#define DebugMessageN9(msg, N1, N2, N3, N4, N5, N6, N7, N8, N9)
|
|
141
|
+
#define DEBUGPRINT(msg)
|
|
142
|
+
#define vprint(msg)
|
|
143
|
+
#define STOP
|
|
144
|
+
#endif
|
|
145
|
+
|
|
146
|
+
void LogError(const char *fmt, ...); // writes to syslog (and stderr if debugging)
|
|
147
|
+
|
|
148
|
+
#define Assert(inCondition, inMessage) \
|
|
149
|
+
if(!(inCondition)) \
|
|
150
|
+
{ \
|
|
151
|
+
DebugMessage(inMessage); \
|
|
152
|
+
STOP; \
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
#define AssertNoError(inError, inMessage) \
|
|
156
|
+
{ \
|
|
157
|
+
SInt32 __E__err = (inError); \
|
|
158
|
+
if(__E__err != 0) \
|
|
159
|
+
{ \
|
|
160
|
+
char __4CC_string[5]; \
|
|
161
|
+
*((SInt32*)__4CC_string) = __E__err; \
|
|
162
|
+
__4CC_string[4] = 0; \
|
|
163
|
+
DebugMessageN2(inMessage ", Error: %ld (%s)", __E__err, __4CC_string); \
|
|
164
|
+
STOP; \
|
|
165
|
+
} \
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
#define AssertNoKernelError(inError, inMessage) \
|
|
169
|
+
{ \
|
|
170
|
+
unsigned int __E__err = (unsigned int)(inError); \
|
|
171
|
+
if(__E__err != 0) \
|
|
172
|
+
{ \
|
|
173
|
+
DebugMessageN1(inMessage ", Error: 0x%X", __E__err); \
|
|
174
|
+
STOP; \
|
|
175
|
+
} \
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
#define FailIf(inCondition, inHandler, inMessage) \
|
|
179
|
+
if(inCondition) \
|
|
180
|
+
{ \
|
|
181
|
+
DebugMessage(inMessage); \
|
|
182
|
+
STOP; \
|
|
183
|
+
goto inHandler; \
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
#define FailWithAction(inCondition, inAction, inHandler, inMessage) \
|
|
187
|
+
if(inCondition) \
|
|
188
|
+
{ \
|
|
189
|
+
DebugMessage(inMessage); \
|
|
190
|
+
STOP; \
|
|
191
|
+
{ inAction; } \
|
|
192
|
+
goto inHandler; \
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
#if defined(__cplusplus)
|
|
196
|
+
|
|
197
|
+
#define ThrowIf(inCondition, inException, inMessage) \
|
|
198
|
+
if(inCondition) \
|
|
199
|
+
{ \
|
|
200
|
+
DebugMessage(inMessage); \
|
|
201
|
+
STOP; \
|
|
202
|
+
throw (inException); \
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
#define ThrowIfNULL(inPointer, inException, inMessage) \
|
|
206
|
+
if((inPointer) == NULL) \
|
|
207
|
+
{ \
|
|
208
|
+
DebugMessage(inMessage); \
|
|
209
|
+
STOP; \
|
|
210
|
+
throw (inException); \
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
#define ThrowIfKernelError(inKernelError, inException, inMessage) \
|
|
214
|
+
{ \
|
|
215
|
+
kern_return_t __E__err = (inKernelError); \
|
|
216
|
+
if(__E__err != 0) \
|
|
217
|
+
{ \
|
|
218
|
+
DebugMessageN1(inMessage ", Error: 0x%X", __E__err); \
|
|
219
|
+
STOP; \
|
|
220
|
+
throw (inException); \
|
|
221
|
+
} \
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
#define ThrowIfError(inError, inException, inMessage) \
|
|
225
|
+
{ \
|
|
226
|
+
SInt32 __E__err = (inError); \
|
|
227
|
+
if(__E__err != 0) \
|
|
228
|
+
{ \
|
|
229
|
+
char __4CC_string[5]; \
|
|
230
|
+
*((SInt32*)__4CC_string) = __E__err; \
|
|
231
|
+
__4CC_string[4] = 0; \
|
|
232
|
+
DebugMessageN2(inMessage ", Error: %ld (%s)", __E__err, __4CC_string); \
|
|
233
|
+
STOP; \
|
|
234
|
+
throw (inException); \
|
|
235
|
+
} \
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
#define ThrowError(inError, inException, inMessage) \
|
|
239
|
+
{ \
|
|
240
|
+
SInt32 __E__err = (inError); \
|
|
241
|
+
char __4CC_string[5]; \
|
|
242
|
+
*((SInt32*)__4CC_string) = __E__err; \
|
|
243
|
+
__4CC_string[4] = 0; \
|
|
244
|
+
DebugMessageN2(inMessage ", Error: %ld (%s)", __E__err, __4CC_string); \
|
|
245
|
+
STOP; \
|
|
246
|
+
throw (inException); \
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
#define SubclassResponsibility(inMethodName, inException) \
|
|
250
|
+
{ \
|
|
251
|
+
DebugMessage(inMethodName": Subclasses must implement this method"); \
|
|
252
|
+
throw (inException); \
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
#endif // defined(__cplusplus)
|
|
256
|
+
|
|
257
|
+
#endif
|