[Speex-dev] Random decoder error/exception
davide at hostinglatorre.it
Thu May 21 09:19:25 UTC 2020
i know this mailing list is basically dead but i try anyways because
i've got a problem and i'm nearly desperate.
I'm writing a realtime voice chat application, with a centralized server
(dedicated) architecture, using C# (dedicated server is a .net core app
while for the client i'm using C# to script the game engine Unity3D).
For the encoding/decoding part i'm using NSpeex, the c# wrapper for
Unity of the Speex.dll library (https://github.com/aijingsun6/NSpeex)
Basically, it works like this:
- Client records from the microphone/soundcard PCM samples and put them
in chunks of X samples each.
- These chunks are then passed to the encoder, when one chuck has been
encoded (async on another thread) a callback is received and the
compressed <byte> is put in a queue for the network
delivery. Each chunk is 554 bytes.
- The dedicated server receives the data and broadcasts to other clients
- The client receives the chunk and makes the opposite: every byte
received is put in a List<byte> which is the first buffer.
When i've got enough bytes to start decoding (554 bytes), the segment is
taken and sent to the decoder.
Once it has been decoded, i take the resulting PCM samples and pass them
to the playing buffer which sends them to the soundcard when i have
enough data to start playing.
Now, it works GOOD! Most of the time...
but from time to time, out of the blue and totally random, the decoder
(and only the decoder) throws an Exception like: "more than two
sidebands found" or "invalid sideband mode" and
simply stops working, making my app unable to continue working.
From my understanding of the Speex library, this means that the decoder
doesn't find the bits where it expect them to be... but WHY it happens
only from time to time?!
I've seen it happen when i feed the encoder/decoder with segments of the
wrong size but in this case i've debugged the hell out of it and i'm
sure i'm passing always the same data amount.
..could this be a network related problem? I don't think so, i'm using
reliable TCP and i'm sure every packet reachs the destination and in the
Anybody has an idea?
Thanks in advance,
More information about the Speex-dev