discordjs / voice

Implementation of the Discord Voice API for discord.js and other JS/TS libraries
Apache License 2.0
327 stars 111 forks source link

refactor(AudioPlayer): use this.once instead of events.once #162

Closed MatteZ02 closed 3 years ago

MatteZ02 commented 3 years ago

Please describe the changes this PR makes and why it should be merged:

This pr replaces the once(this.playStream, 'readable') listener inside audioResouce with a proper this.playStream.once(...) listener. Personally i experienced alot of audioPlayer failed to enter state playing in ????ms errors prior to this fix. The timeout duration had no effect on this. I calculated that there was a 6 ms latency when using once(...) compared to this.playStream.once(...). During this 6 ms the audioPlayer.play() function executed missing the if statement for resouce.playing and attaching the event listeners after audioResouce readable event emitted.

Status and versioning classification:

codecov[bot] commented 3 years ago

Codecov Report

Merging #162 (eaea890) into main (516bc3b) will decrease coverage by 0.03%. The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #162      +/-   ##
==========================================
- Coverage   68.65%   68.61%   -0.04%     
==========================================
  Files          19       19              
  Lines         906      905       -1     
  Branches      221      221              
==========================================
- Hits          622      621       -1     
  Misses        282      282              
  Partials        2        2              
Impacted Files Coverage Δ
src/audio/AudioResource.ts 96.66% <100.00%> (-0.06%) :arrow_down:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 516bc3b...eaea890. Read the comment docs.