1 /* 2 =========================================================================== 3 Copyright (C) 1999-2005 Id Software, Inc. 4 Copyright (C) 2005 Stuart Dalton (badcdev@gmail.com) 5 6 This file is part of Quake III Arena source code. 7 8 Quake III Arena source code is free software; you can redistribute it 9 and/or modify it under the terms of the GNU General Public License as 10 published by the Free Software Foundation; either version 2 of the License, 11 or (at your option) any later version. 12 13 Quake III Arena source code is distributed in the hope that it will be 14 useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 GNU General Public License for more details. 17 18 You should have received a copy of the GNU General Public License 19 along with Quake III Arena source code; if not, write to the Free Software 20 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 21 =========================================================================== 22 */ 23 24 #ifndef _SND_CODEC_H_ 25 #define _SND_CODEC_H_ 26 27 #include "../qcommon/q_shared.h" 28 #include "../qcommon/qcommon.h" 29 30 typedef struct snd_info_s 31 { 32 int rate; 33 int width; 34 int channels; 35 int samples; 36 int size; 37 int dataofs; 38 } snd_info_t; 39 40 typedef struct snd_codec_s snd_codec_t; 41 42 typedef struct snd_stream_s 43 { 44 snd_codec_t *codec; 45 fileHandle_t file; 46 snd_info_t info; 47 int length; 48 int pos; 49 void *ptr; 50 } snd_stream_t; 51 52 // Codec functions 53 typedef void *(*CODEC_LOAD)(const char *filename, snd_info_t *info); 54 typedef snd_stream_t *(*CODEC_OPEN)(const char *filename); 55 typedef int (*CODEC_READ)(snd_stream_t *stream, int bytes, void *buffer); 56 typedef void (*CODEC_CLOSE)(snd_stream_t *stream); 57 58 // Codec data structure 59 struct snd_codec_s 60 { 61 char *ext; 62 CODEC_LOAD load; 63 CODEC_OPEN open; 64 CODEC_READ read; 65 CODEC_CLOSE close; 66 snd_codec_t *next; 67 }; 68 69 // Codec management 70 void S_CodecInit( void ); 71 void S_CodecShutdown( void ); 72 void S_CodecRegister(snd_codec_t *codec); 73 void *S_CodecLoad(const char *filename, snd_info_t *info); 74 snd_stream_t *S_CodecOpenStream(const char *filename); 75 void S_CodecCloseStream(snd_stream_t *stream); 76 int S_CodecReadStream(snd_stream_t *stream, int bytes, void *buffer); 77 78 // Util functions (used by codecs) 79 snd_stream_t *S_CodecUtilOpen(const char *filename, snd_codec_t *codec); 80 void S_CodecUtilClose(snd_stream_t **stream); 81 82 // WAV Codec 83 extern snd_codec_t wav_codec; 84 void *S_WAV_CodecLoad(const char *filename, snd_info_t *info); 85 snd_stream_t *S_WAV_CodecOpenStream(const char *filename); 86 void S_WAV_CodecCloseStream(snd_stream_t *stream); 87 int S_WAV_CodecReadStream(snd_stream_t *stream, int bytes, void *buffer); 88 89 // Ogg Vorbis codec 90 #ifdef USE_CODEC_VORBIS 91 extern snd_codec_t ogg_codec; 92 void *S_OGG_CodecLoad(const char *filename, snd_info_t *info); 93 snd_stream_t *S_OGG_CodecOpenStream(const char *filename); 94 void S_OGG_CodecCloseStream(snd_stream_t *stream); 95 int S_OGG_CodecReadStream(snd_stream_t *stream, int bytes, void *buffer); 96 #endif // USE_CODEC_VORBIS 97 98 #endif // !_SND_CODEC_H_ 99