12024
|
1 /*
|
|
2 The mediastreamer library aims at providing modular media processing and I/O
|
|
3 for linphone, but also for any telephony application.
|
|
4 Copyright (C) 2001 Simon MORLAT simon.morlat@linphone.org
|
|
5
|
|
6 This library is free software; you can redistribute it and/or
|
|
7 modify it under the terms of the GNU Lesser General Public
|
|
8 License as published by the Free Software Foundation; either
|
|
9 version 2.1 of the License, or (at your option) any later version.
|
|
10
|
|
11 This library is distributed in the hope that it will be useful,
|
|
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
14 Lesser General Public License for more details.
|
|
15
|
|
16 You should have received a copy of the GNU Lesser General Public
|
|
17 License along with this library; if not, write to the Free Software
|
|
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
19 */
|
|
20
|
|
21
|
|
22
|
|
23 #ifndef SNDCARD_H
|
|
24 #define SNDCARD_H
|
|
25
|
|
26 #undef PACKAGE
|
|
27 #undef VERSION
|
|
28 #include <config.h>
|
|
29 #undef PACKAGE
|
|
30 #undef VERSION
|
|
31
|
|
32 #ifdef HAVE_GLIB
|
|
33 #include <glib.h>
|
|
34 #else
|
|
35 #include <uglib.h>
|
|
36 #endif
|
|
37
|
|
38 #ifdef __cplusplus
|
|
39 extern "C" {
|
|
40 #endif
|
|
41
|
|
42 /* the base class for all soundcards: SndCard */
|
|
43 struct _SndCard;
|
|
44
|
|
45 typedef int (*SndCardOpenFunc)(struct _SndCard*,int, int, int);
|
|
46 typedef void (*SndCardSetBlockingModeFunc)(struct _SndCard*, gboolean );
|
|
47 typedef void (*SndCardCloseFunc)(struct _SndCard*);
|
|
48 typedef gint (*SndCardIOFunc)(struct _SndCard*,char *,int);
|
|
49 typedef void (*SndCardDestroyFunc)(struct _SndCard*);
|
|
50 typedef gboolean (*SndCardPollFunc)(struct _SndCard*);
|
|
51 typedef gint (*SndCardMixerGetLevelFunc)(struct _SndCard*,gint);
|
|
52 typedef void (*SndCardMixerSetRecSourceFunc)(struct _SndCard*,gint);
|
|
53 typedef void (*SndCardMixerSetLevelFunc)(struct _SndCard*,gint ,gint);
|
|
54 typedef struct _MSFilter * (*SndCardCreateFilterFunc)(struct _SndCard *);
|
|
55
|
|
56 struct _SndCard
|
|
57 {
|
|
58 gchar *card_name; /* SB16 PCI for example */
|
|
59 gint index;
|
|
60 gint bsize;
|
|
61 gint rate;
|
|
62 gint stereo;
|
|
63 gint bits;
|
|
64 gint flags;
|
|
65 #define SND_CARD_FLAGS_OPENED 1
|
|
66 SndCardOpenFunc _probe;
|
|
67 SndCardOpenFunc _open_r;
|
|
68 SndCardOpenFunc _open_w;
|
|
69 SndCardSetBlockingModeFunc _set_blocking_mode;
|
|
70 SndCardPollFunc _can_read;
|
|
71 SndCardIOFunc _read;
|
|
72 SndCardIOFunc _write;
|
|
73 SndCardCloseFunc _close_r;
|
|
74 SndCardCloseFunc _close_w;
|
|
75 SndCardMixerGetLevelFunc _get_level;
|
|
76 SndCardMixerSetLevelFunc _set_level;
|
|
77 SndCardMixerSetRecSourceFunc _set_rec_source;
|
|
78 SndCardCreateFilterFunc _create_read_filter;
|
|
79 SndCardCreateFilterFunc _create_write_filter;
|
|
80 SndCardDestroyFunc _destroy;
|
|
81 };
|
|
82
|
|
83
|
|
84 typedef struct _SndCard SndCard;
|
|
85
|
|
86 void snd_card_init(SndCard *obj);
|
|
87 void snd_card_uninit(SndCard *obj);
|
|
88 gint snd_card_probe(SndCard *obj, int bits, int stereo, int rate);
|
|
89 int snd_card_open_r(SndCard *obj, int bits, int stereo, int rate);
|
|
90 int snd_card_open_w(SndCard *obj, int bits, int stereo, int rate);
|
|
91 int snd_card_get_bsize(SndCard *obj);
|
|
92 gboolean snd_card_can_read(SndCard *obj);
|
|
93 int snd_card_read(SndCard *obj,char *buffer,int size);
|
|
94 int snd_card_write(SndCard *obj,char *buffer,int size);
|
|
95 void snd_card_set_blocking_mode(SndCard *obj,gboolean yesno);
|
|
96 void snd_card_close_r(SndCard *obj);
|
|
97 void snd_card_close_w(SndCard *obj);
|
|
98
|
|
99 void snd_card_set_rec_source(SndCard *obj, int source); /* source='l' or 'm'*/
|
|
100 void snd_card_set_level(SndCard *obj, int way, int level);
|
|
101 gint snd_card_get_level(SndCard *obj,int way);
|
|
102
|
|
103 const gchar *snd_card_get_identifier(SndCard *obj);
|
|
104
|
|
105 struct _MSFilter * snd_card_create_read_filter(SndCard *sndcard);
|
|
106 struct _MSFilter * snd_card_create_write_filter(SndCard *sndcard);
|
|
107
|
|
108
|
|
109 #define SND_CARD_LEVEL_GENERAL 1
|
|
110 #define SND_CARD_LEVEL_INPUT 2
|
|
111 #define SND_CARD_LEVEL_OUTPUT 3
|
|
112
|
|
113
|
|
114 int snd_card_destroy(SndCard *obj);
|
|
115
|
|
116 #define SND_CARD(obj) ((SndCard*)(obj))
|
|
117
|
|
118
|
|
119
|
|
120
|
|
121 /* SndCardManager */
|
|
122
|
|
123 #define MAX_SND_CARDS 20
|
|
124
|
|
125
|
|
126 struct _SndCardManager
|
|
127 {
|
|
128 SndCard *cards[MAX_SND_CARDS];
|
|
129 };
|
|
130
|
|
131 typedef struct _SndCardManager SndCardManager;
|
|
132
|
|
133 void snd_card_manager_init(SndCardManager *manager);
|
|
134 SndCard * snd_card_manager_get_card(SndCardManager *manager,int index);
|
|
135 SndCard * snd_card_manager_get_card_with_string(SndCardManager *manager,const char *cardname,int *index);
|
|
136
|
|
137 extern SndCardManager *snd_card_manager;
|
|
138
|
|
139 #ifdef __cplusplus
|
|
140 }
|
|
141 #endif
|
|
142
|
|
143 #endif
|