Skip to content

Commit 7a2a718

Browse files
test: track MediaStreamAudioSourceNode resampling support
1 parent e86e8e8 commit 7a2a718

File tree

3 files changed

+69
-0
lines changed

3 files changed

+69
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
describe('MediaStreamAudioSourceNode', () => {
2+
let mediaStreamAudioDestinationNode;
3+
4+
afterEach(() => mediaStreamAudioDestinationNode.context.close());
5+
6+
beforeEach(() => {
7+
mediaStreamAudioDestinationNode = new MediaStreamAudioDestinationNode(new AudioContext());
8+
});
9+
10+
// bug #212
11+
12+
it('should not allow using a stream with a different sampleRate', async () => {
13+
const audioContext = new AudioContext({ sampleRate: mediaStreamAudioDestinationNode.context.sampleRate === 44100 ? 48000 : 44100 });
14+
15+
try {
16+
expect(() => new MediaStreamAudioSourceNode(audioContext, { mediaStream: mediaStreamAudioDestinationNode.stream }))
17+
.to.throw(DOMException)
18+
.to.include({ code: 9, name: 'NotSupportedError' });
19+
} finally {
20+
await audioContext.close();
21+
}
22+
});
23+
});
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
describe('MediaStreamAudioSourceNode', () => {
2+
let mediaStreamAudioDestinationNode;
3+
4+
afterEach(() => mediaStreamAudioDestinationNode.context.close());
5+
6+
beforeEach(() => {
7+
mediaStreamAudioDestinationNode = new MediaStreamAudioDestinationNode(new AudioContext());
8+
});
9+
10+
// bug #212
11+
12+
it('should not allow using a stream with a different sampleRate', async () => {
13+
const audioContext = new AudioContext({ sampleRate: mediaStreamAudioDestinationNode.context.sampleRate === 44100 ? 48000 : 44100 });
14+
15+
try {
16+
expect(() => new MediaStreamAudioSourceNode(audioContext, { mediaStream: mediaStreamAudioDestinationNode.stream }))
17+
.to.throw(DOMException)
18+
.to.include({ code: 9, name: 'NotSupportedError' });
19+
} finally {
20+
await audioContext.close();
21+
}
22+
});
23+
});
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
describe('MediaStreamAudioSourceNode', () => {
2+
let mediaStreamAudioDestinationNode;
3+
4+
afterEach(() => mediaStreamAudioDestinationNode.context.close());
5+
6+
beforeEach(() => {
7+
mediaStreamAudioDestinationNode = new MediaStreamAudioDestinationNode(new AudioContext());
8+
});
9+
10+
// bug #212
11+
12+
it('should not allow using a stream with a different sampleRate', async () => {
13+
const audioContext = new AudioContext({ sampleRate: mediaStreamAudioDestinationNode.context.sampleRate === 44100 ? 48000 : 44100 });
14+
15+
try {
16+
expect(() => new MediaStreamAudioSourceNode(audioContext, { mediaStream: mediaStreamAudioDestinationNode.stream }))
17+
.to.throw(DOMException)
18+
.to.include({ code: 9, name: 'NotSupportedError' });
19+
} finally {
20+
await audioContext.close();
21+
}
22+
});
23+
});

0 commit comments

Comments
 (0)