author | mickeyl <mickeyl> | 2003-06-15 12:47:05 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2003-06-15 12:47:05 (UTC) |
commit | 24d20c74b8e02ad7b7575ab8f577880f98e43655 (patch) (unidiff) | |
tree | f10e70dc26d89012e70a7763bfea78ac14971650 /libopie2/opiemm/osoundsystem.h | |
parent | 6b682070b6d83f3537dd9fa5aee715ab142a04e6 (diff) | |
download | opie-24d20c74b8e02ad7b7575ab8f577880f98e43655.zip opie-24d20c74b8e02ad7b7575ab8f577880f98e43655.tar.gz opie-24d20c74b8e02ad7b7575ab8f577880f98e43655.tar.bz2 |
just a check-in before i lose that because of my fscking harddrive...
this is work-in-progress...
Diffstat (limited to 'libopie2/opiemm/osoundsystem.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie2/opiemm/osoundsystem.h | 216 |
1 files changed, 216 insertions, 0 deletions
diff --git a/libopie2/opiemm/osoundsystem.h b/libopie2/opiemm/osoundsystem.h new file mode 100644 index 0000000..096d397 --- a/dev/null +++ b/libopie2/opiemm/osoundsystem.h | |||
@@ -0,0 +1,216 @@ | |||
1 | /* | ||
2 | This file is part of the Opie Project | ||
3 | |||
4 | (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> | ||
5 | =. | ||
6 | .=l. | ||
7 | .>+-= | ||
8 | _;:, .> :=|. This program is free software; you can | ||
9 | .> <`_, > . <= redistribute it and/or modify it under | ||
10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | ||
11 | .="- .-=="i, .._ License as published by the Free Software | ||
12 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
13 | ._= =} : or (at your option) any later version. | ||
14 | .%`+i> _;_. | ||
15 | .i_,=:_. -<s. This program is distributed in the hope that | ||
16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
17 | : .. .:, . . . without even the implied warranty of | ||
18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
20 | ..}^=.= = ; Library General Public License for more | ||
21 | ++= -. .` .: details. | ||
22 | : = ...= . :.=- | ||
23 | -. .:....=;==+<; You should have received a copy of the GNU | ||
24 | -_. . . )=. = Library General Public License along with | ||
25 | -- :-=` this library; see the file COPYING.LIB. | ||
26 | If not, write to the Free Software Foundation, | ||
27 | Inc., 59 Temple Place - Suite 330, | ||
28 | Boston, MA 02111-1307, USA. | ||
29 | |||
30 | */ | ||
31 | |||
32 | #ifndef OSOUNDSYSTEM_H | ||
33 | #define OSOUNDSYSTEM_H | ||
34 | |||
35 | #include <qobject.h> | ||
36 | #include <qdict.h> | ||
37 | #include <qmap.h> | ||
38 | |||
39 | class OAudioInterface; | ||
40 | class OMixerInterface; | ||
41 | class OSoundCard; | ||
42 | |||
43 | /*====================================================================================== | ||
44 | * OSoundSystem | ||
45 | *======================================================================================*/ | ||
46 | |||
47 | /** | ||
48 | * @brief A container class for all audio interfaces | ||
49 | * | ||
50 | * This class provides access to all available audio/midi/sequencer interfaces of your computer. | ||
51 | * | ||
52 | * @author Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> | ||
53 | */ | ||
54 | class OSoundSystem : public QObject | ||
55 | { | ||
56 | Q_OBJECT | ||
57 | |||
58 | public: | ||
59 | typedef QDict<OSoundCard> CardMap; | ||
60 | typedef QDictIterator<OSoundCard> CardIterator; | ||
61 | |||
62 | public: | ||
63 | /** | ||
64 | * @returns the number of available interfaces | ||
65 | */ | ||
66 | int count() const; | ||
67 | /** | ||
68 | * @returns a pointer to the (one and only) @ref ONetwork instance. | ||
69 | */ | ||
70 | static OSoundSystem* instance(); | ||
71 | /** | ||
72 | * @returns an iterator usable for iterating through all network interfaces. | ||
73 | */ | ||
74 | CardIterator iterator() const; | ||
75 | /** | ||
76 | * @returns a pointer to the @ref OAudioInterface object for the specified @a interface or 0, if not found | ||
77 | * @see OAudioInterface | ||
78 | */ | ||
79 | OSoundCard* card( const QString& interface ) const; | ||
80 | /** | ||
81 | * @internal Rebuild the internal interface database | ||
82 | * @note Sometimes it might be useful to call this from client code, | ||
83 | * e.g. after issuing a cardctl insert | ||
84 | */ | ||
85 | void synchronize(); | ||
86 | |||
87 | protected: | ||
88 | OSoundSystem(); | ||
89 | |||
90 | private: | ||
91 | static OSoundSystem* _instance; | ||
92 | CardMap _interfaces; | ||
93 | }; | ||
94 | |||
95 | |||
96 | /*====================================================================================== | ||
97 | * OSoundCard | ||
98 | *======================================================================================*/ | ||
99 | |||
100 | class OSoundCard : public QObject | ||
101 | { | ||
102 | Q_OBJECT | ||
103 | |||
104 | public: | ||
105 | /** | ||
106 | * Constructor. Normally you don't create @ref OSoundCard objects yourself, | ||
107 | * but access them via @ref OSoundSystem::card(). | ||
108 | */ | ||
109 | OSoundCard( QObject* parent, const char* name ); | ||
110 | /** | ||
111 | * Destructor. | ||
112 | */ | ||
113 | virtual ~OSoundCard(); | ||
114 | |||
115 | bool hasMixer() const { return _audio; }; | ||
116 | bool hasAudio() const { return _mixer; }; | ||
117 | |||
118 | OAudioInterface* audio() const { return _audio; }; | ||
119 | OMixerInterface* mixer() const { return _mixer; }; | ||
120 | |||
121 | protected: | ||
122 | OAudioInterface* _audio; | ||
123 | OMixerInterface* _mixer; | ||
124 | |||
125 | private: | ||
126 | void init(); | ||
127 | }; | ||
128 | |||
129 | /*====================================================================================== | ||
130 | * OAudioInterface | ||
131 | *======================================================================================*/ | ||
132 | |||
133 | class OAudioInterface : public QObject | ||
134 | { | ||
135 | Q_OBJECT | ||
136 | |||
137 | public: | ||
138 | /** | ||
139 | * Constructor. Normally you don't create @ref OAudioInterface objects yourself, | ||
140 | * but access them via the @ref OSoundCard interface. | ||
141 | */ | ||
142 | OAudioInterface( QObject* parent, const char* name ); | ||
143 | /** | ||
144 | * Destructor. | ||
145 | */ | ||
146 | virtual ~OAudioInterface(); | ||
147 | |||
148 | protected: | ||
149 | const int _sfd; | ||
150 | |||
151 | private: | ||
152 | void init(); | ||
153 | }; | ||
154 | |||
155 | |||
156 | /*====================================================================================== | ||
157 | * OMixerInterface | ||
158 | *======================================================================================*/ | ||
159 | |||
160 | class OMixerInterface : public QObject | ||
161 | { | ||
162 | Q_OBJECT | ||
163 | |||
164 | public: | ||
165 | |||
166 | typedef QMap<QString,int>::ConstIterator ChannelIterator; | ||
167 | |||
168 | /** | ||
169 | * Constructor. Normally you don't create @ref OMixerInterface objects yourself, | ||
170 | * but access them via the @ref OSoundCard interface. | ||
171 | */ | ||
172 | OMixerInterface( QObject* parent, const char* name ); | ||
173 | /** | ||
174 | * Destructor. | ||
175 | */ | ||
176 | virtual ~OMixerInterface(); | ||
177 | |||
178 | /** | ||
179 | * @returns all available channels. | ||
180 | */ | ||
181 | QStringList allChannels() const; | ||
182 | /** | ||
183 | * @returns recordable channels. | ||
184 | */ | ||
185 | QStringList recChannels() const; | ||
186 | /** | ||
187 | * @returns playable channels. | ||
188 | */ | ||
189 | QStringList playChannels() const; | ||
190 | |||
191 | /** | ||
192 | * @returns true, if @a channel exists. | ||
193 | */ | ||
194 | bool hasChannel( const QString& channel ); | ||
195 | |||
196 | /** | ||
197 | * Set the @a left and @a right volumes for @a channel. | ||
198 | * If no value for right is given, the value for left is taken for that. | ||
199 | */ | ||
200 | void setVolume( const QString& channel, int left, int right = -1 ); | ||
201 | /** | ||
202 | * @returns the volume of @a channel or -1, if the channel doesn't exist. | ||
203 | * @note You might want to use @ref hasChannel() to check if a channel exists. | ||
204 | */ | ||
205 | int volume( const QString& channel ) const; | ||
206 | |||
207 | protected: | ||
208 | int _fd; | ||
209 | QMap<QString, int> _channels; | ||
210 | |||
211 | private: | ||
212 | void init(); | ||
213 | }; | ||
214 | |||
215 | #endif // OSOUNDSYSTEM_H | ||
216 | |||