Closed Pranav-Badrinathan closed 1 year ago
To my knowledge this is intended; maybe it shouldn't panic, but equally your audio frames need to be small enough to fit in a single UDP packet without fragmenting. The current limit takes some headroom under the typical MTU since there's variation among ISPs -- it could stand to go up a bit, possibly.
My back of the napkin math suggests your frames are encoded at... 572kbps assuming 20ms each? I don't think Discord are smart enough to stop you regardless, but that does seem a tad extreme.
So in that case play_sound
should be called per audio frame? In this case I was combining multiple frames and calling the function for each combined collection, hence the large size.
Closing this then, as this is not a bug. Thanks for taking the time to reply, and sorry for the inconvenience!
Not necessarily per audio frame; if you're stuffing ~5 frames into a packet, if you know their length then you can just write out the length of each individually. I.e. (header) | len(frame1) | frame1 | len(frame2) | frame2 | len(frame3) | ...
. If this needs to be longer-lived, you could presumably write a custom Read
implementation which blocks on receiving frames, reads into an internal buffer, and then handles this transformation for each packet.
I was doing the same without the header
, and it was playing the first frame, skipping the rest. If it is required to qualify each packet as a file made up of multiple frames, I'll attempt it with the header
.
If not, I can simply just play it frame by frame. Thanks!
Songbird version: 0.3.2
Rust version (
rustc -V
): 1.70.0Serenity/Twilight version: Serenity 0.11.5
Output of
ffmpeg -version
,yt-dlp --version
(if relevant): Not relavantDescription:
This could be a bug, or intended. When passing in
Opus
frames withContainer::Dca
to create anInput
(relevant discussion) and passing it over toplay_source
to be played, the playback thread always panics if the frame size is over 1432 bytes exactly. This seems to have something to do withVOICE_PACKET_MAX
, which is used inMixer::new
to initialize an array of zeroes.The confusing part is, when debugging, I saw that the code panicked here, where
buffer
was a slice with only zeroes and length 1432 (NOT the data used to initializeReader
), butframe.frame_len
was the length of the frame sent intoplay_source
. This possibly looks like the array initialized withVOICE_PACKET_MAX
that I mentioned above, but with a length value equal to the data passed intoplay_source
.Backtrace, if it is helpful.
``` thread 'Steps to reproduce:
Dca
spec required frame lengths at the start of each frame. Make sure that each frame is bigger than 1432 bytes in size.Input
usingplay_source
.Sorry for the trouble is this is not a bug, I just can't completely follow the route the code takes to end up this way.