File: sound.h

package info (click to toggle)
searchandrescue 0.8.2-10
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 4,656 kB
  • ctags: 6,111
  • sloc: ansic: 89,072; cpp: 7,691; sh: 90; makefile: 80
file content (153 lines) | stat: -rw-r--r-- 3,600 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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
/*
			       Sound Server IO
 */

#ifndef SOUND_H
#define SOUND_H

#include <sys/types.h>

/*
 *	Sound flags type:
 */
#define snd_flags_t	unsigned int


/*
 *	Sound priority levels:
 */
#define SND_PRIORITY_BACKGROUND		0
#define SND_PRIORITY_FOREGROUND		1
#define SND_PRIORITY_PREEMPT		2


/*
 *	Sound play options:
 */
#define SND_PLAY_OPTION_MUTE		(1 << 0)
#define SND_PLAY_OPTION_REPEATING	(1 << 1)


/*
 *      Sound object play structure:
 *
 *	For keeping track of currently playing sound objects.
 */
typedef struct {

	/* Pointer to sound server specific play id. */
	void *data;

	/* Last set volume (from 0.0 to 1.0). This is used to check
	 * if sound play values actually need to be adjusted when
	 * requested.
	 */
	float volume_left, volume_right;

	/* Applied sample rate. */
	int sample_rate;

	/* Play options. */
	snd_flags_t options;

} snd_play_struct;

#define SND_PLAY(p)	((snd_play_struct *)(p))


/*
 *	Recorder (sound server connection) structure:
 */
typedef struct {

#define SNDSERV_TYPE_NONE	0
#define SNDSERV_TYPE_Y		1

	/* Sound server type, one of SNDSERV_TYPE_*. */
	int type;

	/* Opaque pointer to the connection to the sound server. */
	void *con;

	/* Current Audio parameters. */
	int sample_rate;
	int sample_size;
	int channels;
	int bytes_per_cycle;

	/* Current background music sound object being played (can be
	 * NULL to indicate no background music being played)
	 */
	snd_play_struct *background_music_sndobj;

} snd_recorder_struct;

#define SND_RECORDER(p)	((snd_recorder_struct *)(p))


extern snd_recorder_struct *SoundInit(
	void *core,
	int type,
	const char *connect_arg,
	const char *start_arg,
	void *window
);
extern int SoundManageEvents(snd_recorder_struct *recorder);
extern void SoundShutdown(snd_recorder_struct *recorder);

extern int SoundChangeMode(
	snd_recorder_struct *recorder, const char *mode_name
);

extern snd_play_struct *SoundStartPlay(
	snd_recorder_struct *recorder,
	const char *object,	/* Full path to object. */
	float volume_left,	/* Volume, from 0.0 to 1.0. */
	float volume_right,
	int sample_rate,	/* Applied sample rate, can be 0. */
	snd_flags_t options	/* Any of SND_PLAY_OPTION_*. */
);
extern void SoundStartPlayVoid(
	snd_recorder_struct *recorder,
	const char *object,	/* Full path to object. */
	float volume_left,     /* Volume, from 0.0 to 1.0. */
	float volume_right,
	int sample_rate,        /* Applied sample rate, can be 0. */
	snd_flags_t options     /* Any of SND_PLAY_OPTION_*. */
);
extern void SoundPlayMute(
	snd_recorder_struct *recorder, snd_play_struct *snd_play,
	int mute  
);
extern void SoundChangePlayVolume(
	snd_recorder_struct *recorder, snd_play_struct *snd_play,
	float volume_left,	/* Volume, from 0.0 to 1.0. */
	float volume_right
);
extern void SoundChangePlaySampleRate(
	snd_recorder_struct *recorder, snd_play_struct *snd_play,
	int sample_rate		/* Applied sample rate, can be 0. */
);
extern void SoundStopPlay(
	snd_recorder_struct *recorder, snd_play_struct *snd_play
);

extern int SoundMusicStartPlay(
	snd_recorder_struct *recorder,
	const char *object,	/* Full path to object. */
	int repeats		/* Number of repeats, -1 for infinate. */
);
extern int SoundMusicIsPlaying(snd_recorder_struct *recorder);
extern void SoundMusicStopPlay(snd_recorder_struct *recorder);

extern void SoundMixerGet(
	snd_recorder_struct *recorder, const char *channel_name,
	float *left, float *right       /* 0.0 to 1.0 */
);
extern void SoundMixerSet(
	snd_recorder_struct *recorder, const char *channel_name,
	float left, float right         /* 0.0 to 1.0 */
);


#endif	/* SOUND_H */