summaryrefslogtreecommitdiff
path: root/libopie2/opiemm
Unidiff
Diffstat (limited to 'libopie2/opiemm') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiemm/opiemm.pro2
-rw-r--r--libopie2/opiemm/osoundsystem.cpp2
-rw-r--r--libopie2/opiemm/osoundsystem.h17
3 files changed, 20 insertions, 1 deletions
diff --git a/libopie2/opiemm/opiemm.pro b/libopie2/opiemm/opiemm.pro
index d6f54ee..ce30dfb 100644
--- a/libopie2/opiemm/opiemm.pro
+++ b/libopie2/opiemm/opiemm.pro
@@ -1,18 +1,18 @@
1TEMPLATE = lib 1TEMPLATE = lib
2CONFIG += qt warn_on debug 2CONFIG += qt warn_on debug
3DESTDIR = $(OPIEDIR)/lib 3DESTDIR = $(OPIEDIR)/lib
4HEADERS = osoundsystem.h 4HEADERS = osoundsystem.h
5SOURCES = osoundsystem.cpp 5SOURCES = osoundsystem.cpp
6INTERFACES = 6INTERFACES =
7TARGET = opiemm2 7TARGET = opiemm2
8VERSION = 1.8.2 8VERSION = 1.9.0
9INCLUDEPATH += $(OPIEDIR)/include 9INCLUDEPATH += $(OPIEDIR)/include
10DEPENDPATH += $(OPIEDIR)/include 10DEPENDPATH += $(OPIEDIR)/include
11 11
12!contains( platform, x11 ) { 12!contains( platform, x11 ) {
13 include ( $(OPIEDIR)/include.pro ) 13 include ( $(OPIEDIR)/include.pro )
14} 14}
15 15
16contains( platform, x11 ) { 16contains( platform, x11 ) {
17 LIBS = -L$(OPIEDIR)/lib -Wl,-rpath,$(OPIEDIR)/lib 17 LIBS = -L$(OPIEDIR)/lib -Wl,-rpath,$(OPIEDIR)/lib
18} 18}
diff --git a/libopie2/opiemm/osoundsystem.cpp b/libopie2/opiemm/osoundsystem.cpp
index 51e088c..07f26c0 100644
--- a/libopie2/opiemm/osoundsystem.cpp
+++ b/libopie2/opiemm/osoundsystem.cpp
@@ -12,64 +12,66 @@
12 - .   .-<_>     .<> Foundation; either version 2 of the License, 12 - .   .-<_>     .<> Foundation; either version 2 of the License,
13     ._= =}       : or (at your option) any later version. 13     ._= =}       : or (at your option) any later version.
14    .%`+i>       _;_. 14    .%`+i>       _;_.
15    .i_,=:_.      -<s. This program is distributed in the hope that 15    .i_,=:_.      -<s. This program is distributed in the hope that
16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
17    : ..    .:,     . . . without even the implied warranty of 17    : ..    .:,     . . . without even the implied warranty of
18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
20..}^=.=       =       ; Library General Public License for more 20..}^=.=       =       ; Library General Public License for more
21++=   -.     .`     .: details. 21++=   -.     .`     .: details.
22 :     =  ...= . :.=- 22 :     =  ...= . :.=-
23 -.   .:....=;==+<; You should have received a copy of the GNU 23 -.   .:....=;==+<; You should have received a copy of the GNU
24  -_. . .   )=.  = Library General Public License along with 24  -_. . .   )=.  = Library General Public License along with
25    --        :-=` this library; see the file COPYING.LIB. 25    --        :-=` this library; see the file COPYING.LIB.
26 If not, write to the Free Software Foundation, 26 If not, write to the Free Software Foundation,
27 Inc., 59 Temple Place - Suite 330, 27 Inc., 59 Temple Place - Suite 330,
28 Boston, MA 02111-1307, USA. 28 Boston, MA 02111-1307, USA.
29 29
30*/ 30*/
31 31
32#include <opie2/osoundsystem.h> 32#include <opie2/osoundsystem.h>
33#include <opie2/odebug.h> 33#include <opie2/odebug.h>
34 34
35#include <errno.h> 35#include <errno.h>
36#include <fcntl.h> 36#include <fcntl.h>
37#include <string.h> 37#include <string.h>
38#include <sys/ioctl.h> 38#include <sys/ioctl.h>
39#include <sys/types.h> 39#include <sys/types.h>
40#include <sys/soundcard.h> 40#include <sys/soundcard.h>
41#include <sys/stat.h> 41#include <sys/stat.h>
42 42
43 43
44using namespace Opie::Core;
45using namespace Opie::MM;
44/*====================================================================================== 46/*======================================================================================
45 * OSoundSystem 47 * OSoundSystem
46 *======================================================================================*/ 48 *======================================================================================*/
47 49
48OSoundSystem* OSoundSystem::_instance = 0; 50OSoundSystem* OSoundSystem::_instance = 0;
49 51
50OSoundSystem::OSoundSystem() 52OSoundSystem::OSoundSystem()
51{ 53{
52 odebug << "OSoundSystem::OSoundSystem()" << oendl; 54 odebug << "OSoundSystem::OSoundSystem()" << oendl;
53 synchronize(); 55 synchronize();
54} 56}
55 57
56void OSoundSystem::synchronize() 58void OSoundSystem::synchronize()
57{ 59{
58 // gather available interfaces by inspecting /dev 60 // gather available interfaces by inspecting /dev
59 //FIXME: we could use SIOCGIFCONF here, but we aren't interested in virtual (e.g. eth0:0) devices 61 //FIXME: we could use SIOCGIFCONF here, but we aren't interested in virtual (e.g. eth0:0) devices
60 //FIXME: Use SIOCGIFCONF anway, because we can disable listing of aliased devices 62 //FIXME: Use SIOCGIFCONF anway, because we can disable listing of aliased devices
61 63
62 _interfaces.clear(); 64 _interfaces.clear();
63 _interfaces.insert( "soundcard", new OSoundCard( this, "soundcard" ) ); 65 _interfaces.insert( "soundcard", new OSoundCard( this, "soundcard" ) );
64 66
65 67
66 /* 68 /*
67 69
68 QString str; 70 QString str;
69 QFile f( "/dev/sound" ); 71 QFile f( "/dev/sound" );
70 bool hasFile = f.open( IO_ReadOnly ); 72 bool hasFile = f.open( IO_ReadOnly );
71 if ( !hasFile ) 73 if ( !hasFile )
72 { 74 {
73 odebug << "OSoundSystem: /dev/sound not existing. No sound devices available" << oendl; 75 odebug << "OSoundSystem: /dev/sound not existing. No sound devices available" << oendl;
74 return; 76 return;
75 } 77 }
diff --git a/libopie2/opiemm/osoundsystem.h b/libopie2/opiemm/osoundsystem.h
index 096d397..3c3b622 100644
--- a/libopie2/opiemm/osoundsystem.h
+++ b/libopie2/opiemm/osoundsystem.h
@@ -7,210 +7,227 @@
7           .>+-= 7           .>+-=
8 _;:,     .>    :=|. This program is free software; you can 8 _;:,     .>    :=|. This program is free software; you can
9.> <`_,   >  .   <= redistribute it and/or modify it under 9.> <`_,   >  .   <= redistribute it and/or modify it under
10:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 10:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
11.="- .-=="i,     .._ License as published by the Free Software 11.="- .-=="i,     .._ License as published by the Free Software
12 - .   .-<_>     .<> Foundation; either version 2 of the License, 12 - .   .-<_>     .<> Foundation; either version 2 of the License,
13     ._= =}       : or (at your option) any later version. 13     ._= =}       : or (at your option) any later version.
14    .%`+i>       _;_. 14    .%`+i>       _;_.
15    .i_,=:_.      -<s. This program is distributed in the hope that 15    .i_,=:_.      -<s. This program is distributed in the hope that
16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
17    : ..    .:,     . . . without even the implied warranty of 17    : ..    .:,     . . . without even the implied warranty of
18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
20..}^=.=       =       ; Library General Public License for more 20..}^=.=       =       ; Library General Public License for more
21++=   -.     .`     .: details. 21++=   -.     .`     .: details.
22 :     =  ...= . :.=- 22 :     =  ...= . :.=-
23 -.   .:....=;==+<; You should have received a copy of the GNU 23 -.   .:....=;==+<; You should have received a copy of the GNU
24  -_. . .   )=.  = Library General Public License along with 24  -_. . .   )=.  = Library General Public License along with
25    --        :-=` this library; see the file COPYING.LIB. 25    --        :-=` this library; see the file COPYING.LIB.
26 If not, write to the Free Software Foundation, 26 If not, write to the Free Software Foundation,
27 Inc., 59 Temple Place - Suite 330, 27 Inc., 59 Temple Place - Suite 330,
28 Boston, MA 02111-1307, USA. 28 Boston, MA 02111-1307, USA.
29 29
30*/ 30*/
31 31
32#ifndef OSOUNDSYSTEM_H 32#ifndef OSOUNDSYSTEM_H
33#define OSOUNDSYSTEM_H 33#define OSOUNDSYSTEM_H
34 34
35#include <qobject.h> 35#include <qobject.h>
36#include <qdict.h> 36#include <qdict.h>
37#include <qmap.h> 37#include <qmap.h>
38 38
39namespace Opie {
40namespace MM {
41
39class OAudioInterface; 42class OAudioInterface;
40class OMixerInterface; 43class OMixerInterface;
41class OSoundCard; 44class OSoundCard;
42 45
43/*====================================================================================== 46/*======================================================================================
44 * OSoundSystem 47 * OSoundSystem
45 *======================================================================================*/ 48 *======================================================================================*/
46 49
47/** 50/**
48 * @brief A container class for all audio interfaces 51 * @brief A container class for all audio interfaces
49 * 52 *
50 * This class provides access to all available audio/midi/sequencer interfaces of your computer. 53 * This class provides access to all available audio/midi/sequencer interfaces of your computer.
51 * 54 *
52 * @author Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> 55 * @author Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
53 */ 56 */
54class OSoundSystem : public QObject 57class OSoundSystem : public QObject
55{ 58{
56 Q_OBJECT 59 Q_OBJECT
57 60
58 public: 61 public:
59 typedef QDict<OSoundCard> CardMap; 62 typedef QDict<OSoundCard> CardMap;
60 typedef QDictIterator<OSoundCard> CardIterator; 63 typedef QDictIterator<OSoundCard> CardIterator;
61 64
62 public: 65 public:
63 /** 66 /**
64 * @returns the number of available interfaces 67 * @returns the number of available interfaces
65 */ 68 */
66 int count() const; 69 int count() const;
67 /** 70 /**
68 * @returns a pointer to the (one and only) @ref ONetwork instance. 71 * @returns a pointer to the (one and only) @ref ONetwork instance.
69 */ 72 */
70 static OSoundSystem* instance(); 73 static OSoundSystem* instance();
71 /** 74 /**
72 * @returns an iterator usable for iterating through all network interfaces. 75 * @returns an iterator usable for iterating through all network interfaces.
73 */ 76 */
74 CardIterator iterator() const; 77 CardIterator iterator() const;
75 /** 78 /**
76 * @returns a pointer to the @ref OAudioInterface object for the specified @a interface or 0, if not found 79 * @returns a pointer to the @ref OAudioInterface object for the specified @a interface or 0, if not found
77 * @see OAudioInterface 80 * @see OAudioInterface
78 */ 81 */
79 OSoundCard* card( const QString& interface ) const; 82 OSoundCard* card( const QString& interface ) const;
80 /** 83 /**
81 * @internal Rebuild the internal interface database 84 * @internal Rebuild the internal interface database
82 * @note Sometimes it might be useful to call this from client code, 85 * @note Sometimes it might be useful to call this from client code,
83 * e.g. after issuing a cardctl insert 86 * e.g. after issuing a cardctl insert
84 */ 87 */
85 void synchronize(); 88 void synchronize();
86 89
87 protected: 90 protected:
88 OSoundSystem(); 91 OSoundSystem();
89 92
90 private: 93 private:
91 static OSoundSystem* _instance; 94 static OSoundSystem* _instance;
92 CardMap _interfaces; 95 CardMap _interfaces;
96 class Private;
97 Private *d;
93}; 98};
94 99
95 100
96/*====================================================================================== 101/*======================================================================================
97 * OSoundCard 102 * OSoundCard
98 *======================================================================================*/ 103 *======================================================================================*/
99 104
100class OSoundCard : public QObject 105class OSoundCard : public QObject
101{ 106{
102 Q_OBJECT 107 Q_OBJECT
103 108
104 public: 109 public:
105 /** 110 /**
106 * Constructor. Normally you don't create @ref OSoundCard objects yourself, 111 * Constructor. Normally you don't create @ref OSoundCard objects yourself,
107 * but access them via @ref OSoundSystem::card(). 112 * but access them via @ref OSoundSystem::card().
108 */ 113 */
109 OSoundCard( QObject* parent, const char* name ); 114 OSoundCard( QObject* parent, const char* name );
110 /** 115 /**
111 * Destructor. 116 * Destructor.
112 */ 117 */
113 virtual ~OSoundCard(); 118 virtual ~OSoundCard();
114 119
115 bool hasMixer() const { return _audio; }; 120 bool hasMixer() const { return _audio; };
116 bool hasAudio() const { return _mixer; }; 121 bool hasAudio() const { return _mixer; };
117 122
118 OAudioInterface* audio() const { return _audio; }; 123 OAudioInterface* audio() const { return _audio; };
119 OMixerInterface* mixer() const { return _mixer; }; 124 OMixerInterface* mixer() const { return _mixer; };
120 125
121 protected: 126 protected:
122 OAudioInterface* _audio; 127 OAudioInterface* _audio;
123 OMixerInterface* _mixer; 128 OMixerInterface* _mixer;
124 129
125 private: 130 private:
126 void init(); 131 void init();
132 private:
133 class Private;
134 Private *d;
127}; 135};
128 136
129/*====================================================================================== 137/*======================================================================================
130 * OAudioInterface 138 * OAudioInterface
131 *======================================================================================*/ 139 *======================================================================================*/
132 140
133class OAudioInterface : public QObject 141class OAudioInterface : public QObject
134{ 142{
135 Q_OBJECT 143 Q_OBJECT
136 144
137 public: 145 public:
138 /** 146 /**
139 * Constructor. Normally you don't create @ref OAudioInterface objects yourself, 147 * Constructor. Normally you don't create @ref OAudioInterface objects yourself,
140 * but access them via the @ref OSoundCard interface. 148 * but access them via the @ref OSoundCard interface.
141 */ 149 */
142 OAudioInterface( QObject* parent, const char* name ); 150 OAudioInterface( QObject* parent, const char* name );
143 /** 151 /**
144 * Destructor. 152 * Destructor.
145 */ 153 */
146 virtual ~OAudioInterface(); 154 virtual ~OAudioInterface();
147 155
148 protected: 156 protected:
149 const int _sfd; 157 const int _sfd;
150 158
151 private: 159 private:
152 void init(); 160 void init();
161 private:
162 class Private;
163 Private *d;
153}; 164};
154 165
155 166
156/*====================================================================================== 167/*======================================================================================
157 * OMixerInterface 168 * OMixerInterface
158 *======================================================================================*/ 169 *======================================================================================*/
159 170
160class OMixerInterface : public QObject 171class OMixerInterface : public QObject
161{ 172{
162 Q_OBJECT 173 Q_OBJECT
163 174
164 public: 175 public:
165 176
166 typedef QMap<QString,int>::ConstIterator ChannelIterator; 177 typedef QMap<QString,int>::ConstIterator ChannelIterator;
167 178
168 /** 179 /**
169 * Constructor. Normally you don't create @ref OMixerInterface objects yourself, 180 * Constructor. Normally you don't create @ref OMixerInterface objects yourself,
170 * but access them via the @ref OSoundCard interface. 181 * but access them via the @ref OSoundCard interface.
171 */ 182 */
172 OMixerInterface( QObject* parent, const char* name ); 183 OMixerInterface( QObject* parent, const char* name );
173 /** 184 /**
174 * Destructor. 185 * Destructor.
175 */ 186 */
176 virtual ~OMixerInterface(); 187 virtual ~OMixerInterface();
177 188
178 /** 189 /**
179 * @returns all available channels. 190 * @returns all available channels.
180 */ 191 */
181 QStringList allChannels() const; 192 QStringList allChannels() const;
182 /** 193 /**
183 * @returns recordable channels. 194 * @returns recordable channels.
184 */ 195 */
185 QStringList recChannels() const; 196 QStringList recChannels() const;
186 /** 197 /**
187 * @returns playable channels. 198 * @returns playable channels.
188 */ 199 */
189 QStringList playChannels() const; 200 QStringList playChannels() const;
190 201
191 /** 202 /**
192 * @returns true, if @a channel exists. 203 * @returns true, if @a channel exists.
193 */ 204 */
194 bool hasChannel( const QString& channel ); 205 bool hasChannel( const QString& channel );
195 206
196 /** 207 /**
197 * Set the @a left and @a right volumes for @a channel. 208 * 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. 209 * If no value for right is given, the value for left is taken for that.
199 */ 210 */
200 void setVolume( const QString& channel, int left, int right = -1 ); 211 void setVolume( const QString& channel, int left, int right = -1 );
201 /** 212 /**
202 * @returns the volume of @a channel or -1, if the channel doesn't exist. 213 * @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. 214 * @note You might want to use @ref hasChannel() to check if a channel exists.
204 */ 215 */
205 int volume( const QString& channel ) const; 216 int volume( const QString& channel ) const;
206 217
207 protected: 218 protected:
208 int _fd; 219 int _fd;
209 QMap<QString, int> _channels; 220 QMap<QString, int> _channels;
210 221
211 private: 222 private:
212 void init(); 223 void init();
224 private:
225 class Private;
226 Private *d;
213}; 227};
214 228
229}
230}
231
215#endif // OSOUNDSYSTEM_H 232#endif // OSOUNDSYSTEM_H
216 233