static sf_count_t vorbis_seek (SF_PRIVATE *psf, int UNUSED (mode), sf_count_t offset) { OGG_PRIVATE *odata = (OGG_PRIVATE *) psf->container_data ; VORBIS_PRIVATE *vdata = (VORBIS_PRIVATE *) psf->codec_data ; if (odata == NULL || vdata == NULL) return 0 ; if (offset < 0) { psf->error = SFE_BAD_SEEK ; return ((sf_count_t) -1) ; } ; if (psf->file.mode == SFM_READ) { sf_count_t target = offset - vdata->loc ; if (target < 0) { /* 12 to allow for OggS bit */ psf_fseek (psf, 12, SEEK_SET) ; vorbis_read_header (psf, 0) ; /* Reset state */ target = offset ; } ; while (target > 0) { sf_count_t m = target > 4096 ? 4096 : target ; /* ** Need to multiply by channels here because the seek is done in ** terms of frames and the read function is done in terms of ** samples. */ vorbis_read_sample (psf, (void *) NULL, m * psf->sf.channels, vorbis_rnull) ; target -= m ; } ; return vdata->loc ; } ; return 0 ; } /* vorbis_seek */
static sf_count_t vorbis_read_d (SF_PRIVATE *psf, double *ptr, sf_count_t lens) { return vorbis_read_sample (psf, (void*) ptr, lens, vorbis_rdouble) ; } /* vorbis_read_d */
static sf_count_t vorbis_read_f (SF_PRIVATE *psf, float *ptr, sf_count_t lens) { return vorbis_read_sample (psf, (void*) ptr, lens, vorbis_rfloat) ; } /* vorbis_read_f */
static sf_count_t vorbis_read_i (SF_PRIVATE *psf, int *ptr, sf_count_t lens) { return vorbis_read_sample (psf, (void*) ptr, lens, vorbis_rint) ; } /* vorbis_read_i */
static sf_count_t vorbis_read_s (SF_PRIVATE *psf, short *ptr, sf_count_t lens) { return vorbis_read_sample (psf, (void*) ptr, lens, vorbis_rshort) ; } /* vorbis_read_s */