diff options
author | Mike Smith <msmith@xiph.org> | 2000-04-21 09:35:03 +0000 |
---|---|---|
committer | Mike Smith <msmith@xiph.org> | 2000-04-21 09:35:03 +0000 |
commit | 0f6113fd8b6046acbaaf7b558431cd72c2a42116 (patch) | |
tree | f8ef2fe6ffc2e62c6c0b7262d0a7ae004cd760d1 /include/vorbis | |
parent | c438ef041713dbd908ab6010603fda02b63791d3 (diff) | |
download | libvorbis-git-0f6113fd8b6046acbaaf7b558431cd72c2a42116.tar.gz |
A new abstracted interface to vorbisfile, using callback functions.
Now ov_open() just calls ov_open_callbacks() with appropriate arguments.
This also contains some minor changes that give a ~10% speedup with gcc,
and changes to vorbisfile.h to allow C++ compilation.
svn path=/trunk/vorbis/; revision=337
Diffstat (limited to 'include/vorbis')
-rw-r--r-- | include/vorbis/vorbisfile.h | 44 |
1 files changed, 35 insertions, 9 deletions
diff --git a/include/vorbis/vorbisfile.h b/include/vorbis/vorbisfile.h index dda73efd..3a9e6aa0 100644 --- a/include/vorbis/vorbisfile.h +++ b/include/vorbis/vorbisfile.h @@ -12,18 +12,41 @@ ******************************************************************** function: stdio-based convenience library for opening/seeking/decoding - last mod: $Id: vorbisfile.h,v 1.2 2000/01/28 09:05:02 xiphmont Exp $ + last mod: $Id: vorbisfile.h,v 1.3 2000/04/21 09:35:03 msmith Exp $ ********************************************************************/ #ifndef _OV_FILE_H_ #define _OV_FILE_H_ +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + #include <stdio.h> #include "codec.h" +/* The function prototypes for the callbacks are basically the same as for + * the stdio functions fread, fseek, fclose, ftell. + * The one difference is that the FILE * arguments have been replaced with + * a void * - this is to be used as a pointer to whatever internal data these + * functions might need. In the stdio case, it's just a FILE * cast to a void * + * + * If you use other functions, check the docs for these functions and return + * the right values. For seek_func(), you *MUST* return -1 if the stream is + * unseekable + */ +typedef struct { + size_t (*read_func) (void *ptr, size_t size, size_t nmemb, void *datasource); + int (*seek_func) (void *datasource, long offset, int whence); + int (*close_func) (void *datasource); + long (*tell_func) (void *datasource); +} ov_callbacks; + + typedef struct { - FILE *f; + void *datasource; /* Pointer to a FILE *, etc. */ int seekable; long offset; long end; @@ -35,9 +58,9 @@ typedef struct { long *offsets; long *dataoffsets; long *serialnos; - int64_t *pcmlengths; + int64_t *pcmlengths; vorbis_info *vi; - vorbis_comment *vc; + vorbis_comment *vc; /* Decoding working state local storage */ int64_t pcm_offset; @@ -50,10 +73,14 @@ typedef struct { vorbis_dsp_state vd; /* central working state for the packet->PCM decoder */ vorbis_block vb; /* local working space for packet->PCM decode */ + ov_callbacks callbacks; + } OggVorbis_File; extern int ov_clear(OggVorbis_File *vf); extern int ov_open(FILE *f,OggVorbis_File *vf,char *initial,long ibytes); +extern int ov_open_callback(void *datasource, OggVorbis_File *vf, + char *initial, long ibytes, ov_callbacks callbacks); extern long ov_bitrate(OggVorbis_File *vf,int i); extern long ov_streams(OggVorbis_File *vf); @@ -78,11 +105,10 @@ extern vorbis_comment *ov_comment(OggVorbis_File *vf,int link); extern long ov_read(OggVorbis_File *vf,char *buffer,int length, int bigendianp,int word,int sgned,int *bitstream); -#endif - - - - +#ifdef __cplusplus +} +#endif /* __cplusplus */ +#endif |