Skip to content

Commit 5596620

Browse files
authored
Add userdata constructor param to AudioFrame (#594)
* feat: add userdata constructor param to AudioFrame * fix: add changeset
1 parent e094320 commit 5596620

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

.changeset/fifty-mice-raise.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@livekit/rtc-node': patch
3+
---
4+
5+
Add userdata constructor param to AudioFrame

packages/livekit-rtc/src/audio_frame.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,25 @@ export class AudioFrame {
1111
channels: number;
1212
samplesPerChannel: number;
1313

14-
private _userdata: Record<string, unknown> = {};
14+
private _userdata: Record<string, unknown>;
1515

1616
// note: if converting from Uint8Array to Int16Array, *do not* use buffer.slice!
1717
// it is marked unstable by Node and can cause undefined behaviour, such as massive chunks of
1818
// noise being added to the end.
1919
// it is recommended to use buffer.subarray instead.
2020
// XXX(nbsp): add this when writing proper docs
21-
constructor(data: Int16Array, sampleRate: number, channels: number, samplesPerChannel: number) {
21+
constructor(
22+
data: Int16Array,
23+
sampleRate: number,
24+
channels: number,
25+
samplesPerChannel: number,
26+
userdata: Record<string, unknown> = {},
27+
) {
2228
this.data = data;
2329
this.sampleRate = sampleRate;
2430
this.channels = channels;
2531
this.samplesPerChannel = samplesPerChannel;
32+
this._userdata = userdata;
2633
}
2734

2835
static create(sampleRate: number, channels: number, samplesPerChannel: number): AudioFrame {

0 commit comments

Comments
 (0)