comparison src/CoreAudio/dbaudiolib.h @ 12:3da1b8942b8b trunk

[svn] - remove src/Input src/Output src/Effect src/General src/Visualization src/Container
author nenolod
date Mon, 18 Sep 2006 03:14:20 -0700
parents src/Output/CoreAudio/dbaudiolib.h@13389e613d67
children f1b6f1b2cdb3
comparison
equal deleted inserted replaced
11:cff1d04026ae 12:3da1b8942b8b
1 /*
2
3 Definitions for dbaudiolib.c
4
5 Author: Bob Dean
6 Copyright (c) 1999
7
8
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public Licensse as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22
23 */
24
25 #ifndef __DB_AUDIOLIB_H_
26 #define __DB_AUDIOLIB_H_
27
28
29 #ifdef __cplusplus
30 extern "C"
31 {
32 #endif
33
34 #include <glib.h>
35 /* #include <dbchannel.h> */
36
37 #define DBAUDIOLIB_VERSION "0.9.8";
38
39
40 /* DBAudioLib Error Codes */
41 /* when possible the actual system error code is left in errno, since it
42 more specifically describes the error */
43
44 enum {
45 ERROR_BASE = 50000,
46 ERROR_NOT_IMPLEMENTED, /* user tried to access functionality that has not yet been implemented. */
47 ERROR_BAD_CHANNEL, /* unknown channel type */
48 ERROR_BAD_PARAM, /* function recieved a bad parameter*/
49 ERROR_NO_FREE_CHANNELS, /* all channels are in use */
50 ERROR_TOO_MUCH_DATA, /* the client gave too muxh data to dbaudiolib, conversion would overrun the internal buffers */
51 ERROR_BAD_SAMPLERATE, /* the samplerate provided is not supported */
52 ERROR_BAD_CHANNELTYPE, /* the channeltype provided is not supported */
53 ERROR_BAD_NUMCH, /* the number of audio channels (stereo or mono) is not supported */
54 ERROR_BAD_FORMAT, /* the input audio format is not supported */
55 ERROR_CHANNEL_IN_USE, /* the requested channel index passed to DBAudio_Init is already in use */
56 ERROR_BAD_CHANNEL_ID, /* the requested channel index passed to DBAudio_Init is out of range */
57 ERROR_TOO_LITTLE_DATA, /* the client gave too little data to dbaudiolib - depreciated */
58 ERROR_NOT_INITIALIZED, /* attempted to use dbaudiolib without a call to DBAudio_Init first */
59 ERROR_INIT_FAILURE /* some part of the init process not related to dbmix failed */
60 };
61
62
63 /* enumeration of sampler state */
64 enum sampler_state_e {SAMPLER_OFF,
65 SAMPLER_RECORD,
66 SAMPLER_PLAY_SINGLE,
67 SAMPLER_PLAY_LOOP,
68 SAMPLER_READY};
69
70 typedef enum sampler_state_e sampler_state;
71
72 #define DBAUDIO_MAX_VOLUME 100
73 #define DBAUDIO_INTERNAL_MAX_VOLUME 128
74 #define DBAUDIO_MIN_VOLUME 0
75
76 #define DBMIX_COPYRIGHT "Copyright (c) 2002 by Robert Michael S Dean"
77 #define DBMIX_VERSION "v0.9.8"
78
79 #define SUCCESS 0
80 #define FAILURE -1
81
82 #ifndef TRUE
83 #define TRUE 1
84 #endif
85
86 #ifndef FALSE
87 #define FALSE 0
88 #endif
89
90 #define MONO 1
91 #define STEREO 2
92
93
94 /*
95 * Message structure used to communicate within dbmix channels
96 */
97
98 #define DBMSG_NONE 0x00000000
99 #define DBMSG_ALL (0xFFFFFFFF & ~DBMSG_SAMPLERLOAD & ~DBMSG_SAMPLERSAVE)
100 #define DBMSG_PAUSE 0x00000001
101 #define DBMSG_UNPAUSE 0x00000002
102 #define DBMSG_PLAY 0x00000004
103 #define DBMSG_STOP 0x00000008
104 #define DBMSG_EJECT 0x00000010
105 #define DBMSG_REWIND 0x00000020
106 #define DBMSG_FFORWARD 0x00000040
107 #define DBMSG_NEXT 0x00000080
108 #define DBMSG_PREV 0x00000100
109 #define DBMSG_MUTE 0x00000200
110 #define DBMSG_UNMUTE 0x00000400
111 #define DBMSG_SAMPLERSIZE 0x00000800
112 #define DBMSG_SAMPLERSAVE 0x00001000
113 #define DBMSG_SAMPLERLOAD 0x00002000
114 #define DBMSG_SAMPLERREC 0x00004000
115 #define DBMSG_SAMPLERSTOP 0x00008000
116 #define DBMSG_SAMPLERLOOP 0x00010000
117 #define DBMSG_SAMPLERONCE 0x00020000
118
119 typedef struct dbfsd_msg_s
120 {
121 long int msg_type;
122 float data;
123 char * datastr;
124 } dbfsd_msg;
125
126 /* enumeration of the different channels types */
127 enum channel_type_e {PIPE_CHANNEL, SOCKET_CHANNEL};
128
129 /* DBAudioLib Prototypes for statically linked libraries */
130 int DBAudio_Init(char * name, int fmt, int rte, int numch,
131 enum channel_type_e type, int chindex);
132 int DBAudio_Ready();
133 int DBAudio_Write(char* buf, int len);
134 int DBAudio_Read(char * buf, int count);
135 int DBAudio_Close();
136 int DBAudio_Set_Volume(int left, int right);
137 int DBAudio_Get_Volume(int *left, int *right);
138 int DBAudio_Pause(int value);
139 char * DBAudio_Get_Version();
140 char * DBAudio_Get_Channel_Name(char * name);
141 int DBAudio_Set_Channel_Name(char * name);
142 enum channel_type_e DBAudio_Get_Channel_Type();
143 int DBAudio_Set_Channel_Type(enum channel_type_e type);
144 int DBAudio_Cue_Enabled();
145 int DBAudio_Set_Cue(int flag);
146 int DBAudio_Get_Cue();
147 int DBAudio_Set_Rate(int rte);
148 int DBAudio_Get_Rate();
149 int DBAudio_Set_Channels(int numch);
150 int DBAudio_Get_Channels();
151 int DBAudio_Set_Format(int fmt);
152 int DBAudio_Get_Format();
153 int DBAudio_Get_Bufsize(int input_bufsize);
154 void DBAudio_perror(char *str);
155 int DBAudio_Set_Message_Handler(void(*message_handler)(dbfsd_msg msg), int msg_flags);
156 int DBAudio_Handle_Message_Queue();
157 int DBAudio_Set_Channel_Flag(unsigned int flag);
158 int DBAudio_Clear_Channel_Flag(unsigned int flag);
159 unsigned int DBAudio_Get_Channel_Flags();
160 int DBAudio_Set_Mute(int value);
161 int DBAudio_Get_Mute();
162 int DBAudio_Sampler_Record();
163 int DBAudio_Sampler_Stop();
164 int DBAudio_Sampler_Loop();
165 int DBAudio_Sampler_Single();
166 int DBAudio_Sampler_Get_Offsets(int * start_offset, int * end_offset);
167 int DBAudio_Sampler_Set_Offsets(int start_offset, int end_offset);
168 int DBAudio_Sampler_Get_Size(int * size);
169 int DBAudio_Sampler_Save(char * filename);
170 int DBAudio_Sampler_Load(char * filename);
171 sampler_state DBAudio_Sampler_Get_State();
172
173 /* structure to hold audiolib functions plugin style for dynamically linked
174 libraries...
175 As functions are added, they are placed at the end of the struct so as
176 not to break clients using older versions of the library
177 */
178 typedef struct
179 {
180 int (*DBAudio_Init)(char * name, int fmt, int rte, int numch,
181 enum channel_type_e type, int chindex);
182 int (*DBAudio_Ready)();
183 int (*DBAudio_Write)(char* buf, int len);
184 int (*DBAudio_Read)(char * buf, int count);
185 int (*DBAudio_Close)();
186 int (*DBAudio_Set_Volume)(int left, int right);
187 int (*DBAudio_Get_Volume)(int *left, int *right);
188 int (*DBAudio_Pause)(int value);
189 char * (*DBAudio_Get_Version)();
190 char * (*DBAudio_Get_Channel_Name)(char * name);
191 int (*DBAudio_Set_Channel_Name)(char * name);
192 enum channel_type_e (*DBAudio_Get_Channel_Type)();
193 int (*DBAudio_Set_Channel_Type)(enum channel_type_e type);
194 int (*DBAudio_Cue_Enabled)();
195 int (*DBAudio_Set_Rate)(int rte);
196 int (*DBAudio_Get_Rate)();
197 int (*DBAudio_Set_Channels)(int numch);
198 int (*DBAudio_Get_Channels)();
199 int (*DBAudio_Set_Format)(int fmt);
200 int (*DBAudio_Get_Format)();
201 int (*DBAudio_Set_Cue)(int flag);
202 int (*DBAudio_Get_Cue)();
203 int (*DBAudio_Get_Bufsize)(int input_bufsize);
204 void (*DBAudio_perror)(char *str);
205 int (*DBAudio_Set_Message_Handler)(void(*message_handler)(dbfsd_msg msg),int msg_flags);
206 int (*DBAudio_Handle_Message_Queue)();
207 int (*DBAudio_Set_Channel_Flag)(unsigned int flag);
208 int (*DBAudio_Clear_Channel_Flag)(unsigned int flag);
209 unsigned int (* DBAudio_Get_Channel_Flags)();
210 int (*DBAudio_Set_Mute)(int value);
211 int (*DBAudio_Get_Mute)();
212 int (*DBAudio_Sampler_Record)();
213 int (*DBAudio_Sampler_Stop)();
214 int (*DBAudio_Sampler_Loop)();
215 int (*DBAudio_Sampler_Single)();
216 int (*DBAudio_Sampler_Get_Offsets)(int * start_offset, int * end_offset);
217 int (*DBAudio_Sampler_Set_Offsets)(int start_offset, int end_offset);
218 int (*DBAudio_Sampler_Get_Size)(int * size);
219 int (*DBAudio_Sampler_Save)(char * filename);
220 int (*DBAudio_Sampler_Load)(char * filename);
221 sampler_state (*DBAudio_Sampler_Get_State)();
222 } DBAudioLibFunctions;
223
224 DBAudioLibFunctions * DBAudio_Get_Functions();
225
226
227 #ifdef __cplusplus
228 }
229 #endif
230
231 #endif /* __DB_AUDIOLIB_H_ */