Skip to content
  • Georg Chini's avatar
    sink-input: Implement resampler pseudo rewinding · da539ed3
    Georg Chini authored and PulseAudio Marge Bot's avatar PulseAudio Marge Bot committed
    This patch uses the two previous patches to implemnt pseudo-rewinding for the
    resamplers by feeding some old data into the resampler after a reset. This is
    necessary because PA is using external resamplers that do not implement
    rewinding.
    
    To get exactly the same output data from the resampler after a rewind if possible,
    the matching period is calculated. This is the number of input samples that produces
    an integral number of output samples. After the matching period, the resampler state
    repeats. If the matching period is not too large, feeding history into the resampler
    will start at a point that is a multiple of the matching period back in time. Then
    the resampler will produce exactly the same samples.
    
    The PA_RESAMPLER_MAX_HISTORY value has been replaced by PA_RESAMPLER_MAX_DELAY_USEC
    and the required number of history samples is calculated from the sink input sample
    rate. The number of history samples can be as large as about 12500.
    
    This fixes glitches during volume changes when the sink runs on a rate different
    from the sink input rate.
    
    Part-of: <!120>
    da539ed3