Skip to content
  • Vincent Penquerc'h's avatar
    opus: fix FEC · 1ef601e7
    Vincent Penquerc'h authored
    FEC may only be used when PLC is enabled on the audio decoder,
    as it relies on empty buffers to generate audio from the next
    buffer. Hooking to the gap events doesn't work as the audio
    decoder does not like more buffers output than it sends.
    
    The length of data to generate using FEC from the next packet
    is determined by rounding the gap duration to nearest. This
    ensures that duration imprecision does not cause quantization
    to 2.5 milliseconds less than available. Doing so causes the
    Opus API to fail decoding. Such duration imprecision is common
    in live cases.
    
    The buffer to consider when determining the length of audio
    to be decoded is the previous buffer when using FEC, and the
    new buffer otherwise. In the FEC case, this means we determine
    the amount of audio from the previous buffer, whether it was
    missing or not (and get the data either from this buffer, or
    the current one if the previous one was missing).
    1ef601e7