-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into nbsp/add/audioresampler
- Loading branch information
Showing
16 changed files
with
237 additions
and
138 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
"@livekit/rtc-node": patch | ||
"livekit-server-sdk": patch | ||
--- | ||
|
||
Fix mutex in livekit-rtc | ||
Fix linter warnings in livekit-server-sdk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// SPDX-FileCopyrightText: 2024 LiveKit, Inc. | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
import { describe, expect, it } from 'vitest'; | ||
import { Mutex } from './utils'; | ||
|
||
describe('Mutex', () => { | ||
it('should not be locked initially', () => { | ||
const mutex = new Mutex(); | ||
expect(mutex.isLocked()).toBe(false); | ||
}); | ||
|
||
it('should lock and unlock correctly', async () => { | ||
const mutex = new Mutex(); | ||
const unlock = await mutex.lock(); | ||
expect(mutex.isLocked()).toBe(true); | ||
unlock(); | ||
expect(mutex.isLocked()).toBe(false); | ||
}); | ||
|
||
it('should handle multiple locks', async () => { | ||
const mutex = new Mutex(2); | ||
const unlock1 = await mutex.lock(); | ||
const unlock2 = await mutex.lock(); | ||
expect(mutex.isLocked()).toBe(true); | ||
unlock1(); | ||
expect(mutex.isLocked()).toBe(false); | ||
const unlock3 = await mutex.lock(); | ||
expect(mutex.isLocked()).toBe(true); | ||
unlock2(); | ||
expect(mutex.isLocked()).toBe(false); | ||
unlock3(); | ||
expect(mutex.isLocked()).toBe(false); | ||
}); | ||
|
||
it('should throw an error when unlocking the same lock twice', async () => { | ||
const mutex = new Mutex(2); | ||
const unlock1 = await mutex.lock(); | ||
const unlock2 = await mutex.lock(); | ||
expect(mutex.isLocked()).toBe(true); | ||
unlock1(); | ||
expect(mutex.isLocked()).toBe(false); | ||
expect(() => unlock1()).toThrow('This unlock method has already been called'); | ||
unlock2(); | ||
expect(mutex.isLocked()).toBe(false); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.