SpaceManiac / discord-rs

Rust library for the Discord chat client API
MIT License
390 stars 94 forks source link

Predefined AudioSource implementations never return None #107

Closed ghost closed 3 years ago

ghost commented 7 years ago

As I was implementing a struct to buffer the Youtube stream I realized that the AudioSources created by the predefined functions don't return None when finished, only Some(0).

https://github.com/SpaceManiac/discord-rs/blob/master/src/voice.rs#L265

I think it should rather return None, since the docs say:

If Some(0) is returned, no audio will be sent this frame, but the audio source will remain active. If None is returned, the audio source is considered to have ended, and read_frame will not be called again.

SpaceManiac commented 7 years ago

I feel like I might have done this intentionally, but thinking about it now, I don't know why. I'll call this worth fixing.

domenicquirl commented 4 years ago

Can you confirm whether the behaviour described by OP is still what's happening under the hood? I came across this while writing a trackable AudioSource wrapper - I noticed a high number of Some(0) at the end of any source, but as far as I could tell from here there must be a None to reset the audio source?