File: snd_codec.h

package info (click to toggle)
quakespasm 0.93.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 4,672 kB
  • sloc: ansic: 52,034; sh: 306; makefile: 263
file content (104 lines) | stat: -rw-r--r-- 3,042 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
/*
 * Audio Codecs: Adapted from ioquake3 with changes.
 * For now, only handles streaming music, not sound effects.
 *
 * Copyright (C) 1999-2005 Id Software, Inc.
 * Copyright (C) 2005 Stuart Dalton <badcdev@gmail.com>
 * Copyright (C) 2010-2012 O.Sezer <sezero@users.sourceforge.net>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or (at
 * your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 *
 * See the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 *
 */

#ifndef _SND_CODEC_H_
#define _SND_CODEC_H_

typedef struct snd_info_s
{
	int rate;
	int bits, width;
	int channels;
	int samples;
	int blocksize;
	int size;
	int dataofs;
} snd_info_t;

typedef enum {
	STREAM_NONE = -1,
	STREAM_INIT,
	STREAM_PAUSE,
	STREAM_PLAY
} stream_status_t;

typedef struct snd_codec_s snd_codec_t;

typedef struct snd_stream_s
{
	fshandle_t fh;
	qboolean pak;
	char name[MAX_QPATH];	/* name of the source file */
	snd_info_t info;
	stream_status_t status;
	snd_codec_t *codec;	/* codec handling this stream */
	void *priv;		/* data private to the codec. */
} snd_stream_t;


void S_CodecInit (void);
void S_CodecShutdown (void);

/* Callers of the following S_CodecOpenStream* functions
 * are reponsible for attaching any path to the filename */

snd_stream_t *S_CodecOpenStreamType (const char *filename, unsigned int type);
	/* Decides according to the required type. */

snd_stream_t *S_CodecOpenStreamAny (const char *filename);
	/* Decides according to file extension. if the
	 * name has no extension, try all available. */

snd_stream_t *S_CodecOpenStreamExt (const char *filename);
	/* Decides according to file extension. the name
	 * MUST have an extension. */

void S_CodecCloseStream (snd_stream_t *stream);
int S_CodecReadStream (snd_stream_t *stream, int bytes, void *buffer);
int S_CodecRewindStream (snd_stream_t *stream);

snd_stream_t *S_CodecUtilOpen(const char *filename, snd_codec_t *codec);
void S_CodecUtilClose(snd_stream_t **stream);


#define CODECTYPE_NONE		0
#define CODECTYPE_MID		(1U << 0)
#define CODECTYPE_MOD		(1U << 1)
#define CODECTYPE_FLAC		(1U << 2)
#define CODECTYPE_WAV		(1U << 3)
#define CODECTYPE_MP3		(1U << 4)
#define CODECTYPE_VORBIS	(1U << 5)
#define CODECTYPE_OPUS		(1U << 6)
#define CODECTYPE_UMX		(1U << 7)

#define CODECTYPE_WAVE		CODECTYPE_WAV
#define CODECTYPE_MIDI		CODECTYPE_MID

int S_CodecIsAvailable (unsigned int type);
	/* return 1 if available, 0 if codec failed init
	 * or -1 if no such codec is present. */

#endif	/* _SND_CODEC_H_ */