struct header_t *sp_open_header(register FILE *fp, int parse_flag, char **error) { register struct header_t *h; int header_size, i; struct field_t **fv; if (fp == FPNULL) return HDRNULL; /* check sanity of arguments */ if (spx_read_header(fp,&header_size,parse_flag,error) < 0) return HDRNULL; if ((! parse_flag) || (farray_fields == 0)) fv = FVNULL; else { fv = spx_get_field_vector(farray_fields); if (fv == FVNULL) { for (i=0; i<farray_fields; i++) (void) spx_deallocate_field(farray[i]); return HDRNULL; } (void) spx_copy_field_vector(farray, fv, farray_fields); } h = spx_allocate_header(farray_fields,fv); if (h == HDRNULL) for (i=0; i<farray_fields; i++) (void) spx_deallocate_field(farray[i]); return h; }
int ogg_speex_open (SF_PRIVATE *psf) { OGG_PRIVATE* odata = psf->container_data ; SPX_PRIVATE* spx = calloc (1, sizeof (SPX_PRIVATE)) ; int error = 0 ; if (odata == NULL) { psf_log_printf (psf, "%s : odata is NULL???\n", __func__) ; return SFE_INTERNAL ; } ; psf->codec_data = spx ; if (spx == NULL) return SFE_MALLOC_FAILED ; if (psf->file.mode == SFM_RDWR) return SFE_BAD_MODE_RW ; if (psf->file.mode == SFM_READ) { /* Call this here so it only gets called once, so no memory is leaked. */ ogg_sync_init (&odata->osync) ; if ((error = spx_read_header (psf))) return error ; #if 0 psf->read_short = spx_read_s ; psf->read_int = spx_read_i ; psf->read_float = spx_read_f ; psf->read_double = spx_read_d ; psf->sf.frames = spx_length (psf) ; #endif } ; psf->codec_close = spx_close ; if (psf->file.mode == SFM_WRITE) { #if 0 /* Set the default spx quality here. */ vdata->quality = 0.4 ; psf->write_header = spx_write_header ; psf->write_short = spx_write_s ; psf->write_int = spx_write_i ; psf->write_float = spx_write_f ; psf->write_double = spx_write_d ; #endif psf->sf.frames = SF_COUNT_MAX ; /* Unknown really */ psf->strings.flags = SF_STR_ALLOW_START ; } ; psf->bytewidth = 1 ; psf->blockwidth = psf->bytewidth * psf->sf.channels ; #if 0 psf->seek = spx_seek ; psf->command = spx_command ; #endif /* FIXME, FIXME, FIXME : Hack these here for now and correct later. */ psf->sf.format = SF_FORMAT_OGG | SF_FORMAT_SPEEX ; psf->sf.sections = 1 ; psf->datalength = 1 ; psf->dataoffset = 0 ; /* End FIXME. */ return error ; } /* ogg_speex_open */