Skip to content

Enhance SpeedNormalizingStream to accept TimeProvider and improve del…#287

Draft
KubaZ2 wants to merge 11 commits intoalphafrom
feature/optimize-speed-normalizing-stream
Draft

Enhance SpeedNormalizingStream to accept TimeProvider and improve del…#287
KubaZ2 wants to merge 11 commits intoalphafrom
feature/optimize-speed-normalizing-stream

Conversation

@KubaZ2
Copy link
Member

@KubaZ2 KubaZ2 commented Mar 3, 2026

…ay handling

@github-actions
Copy link

github-actions bot commented Mar 3, 2026

The documentation preview is available at https://preview.netcord.dev/287.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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? to VoiceStreamConfiguration (defaulting to TimeProvider.System).
  • Passed the configured TimeProvider through VoiceClient.CreateVoiceStream into SpeedNormalizingStream.
  • Refactored SpeedNormalizingStream to use TimeProvider timestamps and a timer-backed ValueTask delay 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.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

KubaZ2 added 2 commits March 5, 2026 01:15
…ncTimerWaiter and improve delay handling logic
…ion and disposal more safely, improving concurrency handling
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);
Copy link

Copilot AI Mar 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
return new ObjectDisposedException(typeof(VoiceOutStream).FullName);
return new ObjectDisposedException(nameof(SpeedNormalizingStream));

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants