OpenMoHAA 0.82.0
Loading...
Searching...
No Matches
snd_codec.h
1/*
2===========================================================================
3Copyright (C) 1999-2005 Id Software, Inc.
4Copyright (C) 2005 Stuart Dalton (badcdev@gmail.com)
5
6This file is part of Quake III Arena source code.
7
8Quake III Arena source code is free software; you can redistribute it
9and/or modify it under the terms of the GNU General Public License as
10published by the Free Software Foundation; either version 2 of the License,
11or (at your option) any later version.
12
13Quake III Arena source code is distributed in the hope that it will be
14useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
15MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16GNU General Public License for more details.
17
18You should have received a copy of the GNU General Public License
19along with Quake III Arena source code; if not, write to the Free Software
20Foundation, 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#ifdef __cplusplus
31extern "C" {
32#endif
33
34typedef struct snd_info_s
35{
36 int rate;
37 float width;
38 int channels;
39 int samples;
40 int size;
41 int dataofs;
42 int dataalign;
43} snd_info_t;
44
45typedef struct snd_codec_s snd_codec_t;
46
47typedef struct snd_stream_s
48{
49 snd_codec_t *codec;
50 fileHandle_t file;
51 snd_info_t info;
52 int length;
53 int pos;
54 void *ptr;
55} snd_stream_t;
56
57// Codec functions
58typedef void *(*CODEC_LOAD)(const char *filename, snd_info_t *info);
59typedef snd_stream_t *(*CODEC_OPEN)(const char *filename);
60typedef int (*CODEC_READ)(snd_stream_t *stream, int bytes, void *buffer);
61typedef void (*CODEC_CLOSE)(snd_stream_t *stream);
62
63// Codec data structure
65{
66 char *ext;
67 CODEC_LOAD load;
68 CODEC_OPEN open;
69 CODEC_READ read;
70 CODEC_CLOSE close;
71 snd_codec_t *next;
72};
73
74// Codec management
75void S_CodecInit( void );
76void S_CodecShutdown( void );
77void S_CodecRegister(snd_codec_t *codec);
78void *S_CodecLoad(const char *filename, snd_info_t *info);
79snd_stream_t *S_CodecOpenStream(const char *filename);
80void S_CodecCloseStream(snd_stream_t *stream);
81int S_CodecReadStream(snd_stream_t *stream, int bytes, void *buffer);
82
83// Util functions (used by codecs)
84snd_stream_t *S_CodecUtilOpen(const char *filename, snd_codec_t *codec);
85void S_CodecUtilClose(snd_stream_t **stream);
86
87// WAV Codec
88extern snd_codec_t wav_codec;
89void *S_WAV_CodecLoad(const char *filename, snd_info_t *info);
90snd_stream_t *S_WAV_CodecOpenStream(const char *filename);
91void S_WAV_CodecCloseStream(snd_stream_t *stream);
92int S_WAV_CodecReadStream(snd_stream_t *stream, int bytes, void *buffer);
93
94// Ogg Vorbis codec
95#ifdef USE_CODEC_VORBIS
96extern snd_codec_t ogg_codec;
97void *S_OGG_CodecLoad(const char *filename, snd_info_t *info);
98snd_stream_t *S_OGG_CodecOpenStream(const char *filename);
99void S_OGG_CodecCloseStream(snd_stream_t *stream);
100int S_OGG_CodecReadStream(snd_stream_t *stream, int bytes, void *buffer);
101#endif // USE_CODEC_VORBIS
102
103// MP3 codec
104#ifdef USE_CODEC_MP3
105extern snd_codec_t mp3_codec;
106void* S_MP3_CodecLoad(const char* filename, snd_info_t * info);
107snd_stream_t * S_MP3_CodecOpenStream(const char* filename);
108void S_MP3_CodecCloseStream(snd_stream_t * stream);
109int S_MP3_CodecReadStream(snd_stream_t * stream, int bytes, void* buffer);
110#endif // USE_CODEC_MP3
111
112// Ogg Opus codec
113#ifdef USE_CODEC_OPUS
114extern snd_codec_t opus_codec;
115void *S_OggOpus_CodecLoad(const char *filename, snd_info_t *info);
116snd_stream_t *S_OggOpus_CodecOpenStream(const char *filename);
117void S_OggOpus_CodecCloseStream(snd_stream_t *stream);
118int S_OggOpus_CodecReadStream(snd_stream_t *stream, int bytes, void *buffer);
119#endif // USE_CODEC_OPUS
120
121#ifdef __cplusplus
122}
123#endif
124
125#endif // !_SND_CODEC_H_
Definition snd_codec.h:65
Definition snd_codec.h:35
Definition snd_codec.h:48