Enhance SpeedNormalizingStream to accept TimeProvider and improve del…#287
Enhance SpeedNormalizingStream to accept TimeProvider and improve del…#287
Conversation
|
The documentation preview is available at https://preview.netcord.dev/287. |
There was a problem hiding this comment.
Pull request overview
This PR updates voice stream speed normalization to support injecting a TimeProvider, allowing customizable timestamp/delay behavior (useful for testing and alternative time sources) while adjusting the internal delay implementation.
Changes:
- Added
TimeProvider?toVoiceStreamConfiguration(defaulting toTimeProvider.System). - Passed the configured
TimeProviderthroughVoiceClient.CreateVoiceStreamintoSpeedNormalizingStream. - Refactored
SpeedNormalizingStreamto useTimeProvidertimestamps and a timer-backedValueTaskdelay source.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| NetCord/Gateway/Voice/VoiceStreamConfiguration.cs | Adds configuration hook for providing a TimeProvider for speed normalization. |
| NetCord/Gateway/Voice/VoiceClient.cs | Threads the configured TimeProvider into the speed-normalizing stream creation path. |
| NetCord/Gateway/Voice/Streams/SpeedNormalizingStream.cs | Reworks delay logic to use TimeProvider timestamps and a reusable timer-based async delay. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…cellation support
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…merWaiter and improve resource management
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…ncTimerWaiter and improve delay handling logic
…ion and disposal more safely, improving concurrency handling
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| [StackTraceHidden] | ||
| private static ObjectDisposedException GetObjectDisposedException() | ||
| { | ||
| return new ObjectDisposedException(typeof(VoiceOutStream).FullName); |
There was a problem hiding this comment.
GetObjectDisposedException() constructs the ObjectDisposedException using typeof(VoiceOutStream).FullName, which doesn’t match the type being disposed here (SpeedNormalizingStream / its helper types). This makes disposal-related failures misleading and harder to diagnose; use the current type (or nameof(SpeedNormalizingStream)) as the objectName instead.
| return new ObjectDisposedException(typeof(VoiceOutStream).FullName); | |
| return new ObjectDisposedException(nameof(SpeedNormalizingStream)); |
…ay handling