Skip to content
  • Timothy B. Terriberry's avatar
    Re-do abstract stream reader API. · e2d7b266
    Timothy B. Terriberry authored
    This changes op_read_func to
    a) Take a single byte count to read instead of an "item" count
        (which the http backend couldn't properly support anyway).
    b) Use integers for buffer sizes to avoid having to worry about
        sign differences and whether size_t is larger or smaller than
        opus_int64, etc.
    c) Return an explicit error code (instead of using errno like
        fread).
       We had already eliminated the use of errno, but we did it by
        treating read errors and EOF identically in all cases.
       This was preventing us from reporting SSL truncation attacks
        from the https backend.
       The https backend now properly reports such errors.
    
    This commit also fixes a bug introduced in 9b57b0c2, where we
     accidentally started passing absolute offsets to the _boundary
     parameter of op_get_next_page() instead of relative offsets.
    We now use absolute offsets in all places, as it is the simpler
     choice.
    This matters now, because the error reported when encountering EOF
     before hitting the _boundary is no longer suppressed (but instead
     reported as OP_EBADLINK).
    
    Finally, it removes the op_page_seek() function.
    Except for the time needed to decode forward after seeking, this
     function was identical in performance to op_pcm_seek(), and Opus
     requires decoding 80 ms of data after seek anyway, so the relative
     benefit is much smaller than with Vorbis.
    A survey of open-source code using libvorbisfile showed that the
     only usages of ov_page_seek() in the wild were calling it to seek
     to the start of the stream, for which op_pcm_seek() already has a
     special case that makes it just as fast.
    
    The documentation was also updated to describe all of these chanes.
    
    This is an incompatible API change.
    e2d7b266