00001 /* 00002 This file is part of the Opie Project 00003 =. (C) 2003-2005 Michael 'Mickey' Lauer <mickey@Vanille.de> 00004 .=l. 00005 .>+-= 00006 _;:, .> :=|. This program is free software; you can 00007 .> <`_, > . <= redistribute it and/or modify it under 00008 :`=1 )Y*s>-.-- : the terms of the GNU Library General Public 00009 .="- .-=="i, .._ License as published by the Free Software 00010 - . .-<_> .<> Foundation; version 2 of the License. 00011 ._= =} : 00012 .%`+i> _;_. 00013 .i_,=:_. -<s. This program is distributed in the hope that 00014 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 00015 : .. .:, . . . without even the implied warranty of 00016 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 00017 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 00018 ..}^=.= = ; Library General Public License for more 00019 ++= -. .` .: details. 00020 : = ...= . :.=- 00021 -. .:....=;==+<; You should have received a copy of the GNU 00022 -_. . . )=. = Library General Public License along with 00023 -- :-=` this library; see the file COPYING.LIB. 00024 If not, write to the Free Software Foundation, 00025 Inc., 59 Temple Place - Suite 330, 00026 Boston, MA 02111-1307, USA. 00027 00028 */ 00029 00030 #ifndef OSOUNDSYSTEM_H 00031 #define OSOUNDSYSTEM_H 00032 00033 #include <qobject.h> 00034 #include <qdict.h> 00035 #include <qmap.h> 00036 00037 namespace Opie { 00038 namespace MM { 00039 00040 class OAudioInterface; 00041 class OMixerInterface; 00042 class OSoundCard; 00043 00044 /*====================================================================================== 00045 * OSoundSystem 00046 *======================================================================================*/ 00047 00055 class OSoundSystem : public QObject 00056 { 00057 Q_OBJECT 00058 00059 public: 00060 typedef QDict<OSoundCard> CardMap; 00061 typedef QDictIterator<OSoundCard> CardIterator; 00062 00063 public: 00067 int count() const; 00071 static OSoundSystem* instance(); 00075 CardIterator iterator() const; 00080 OSoundCard* card( const QString& interface ) const; 00086 void synchronize(); 00087 00088 protected: 00089 OSoundSystem(); 00090 00091 private: 00092 static OSoundSystem* _instance; 00093 CardMap _interfaces; 00094 class Private; 00095 Private *d; 00096 }; 00097 00098 00099 /*====================================================================================== 00100 * OSoundCard 00101 *======================================================================================*/ 00102 00103 class OSoundCard : public QObject 00104 { 00105 Q_OBJECT 00106 00107 public: 00112 OSoundCard( QObject* parent, const char* name ); 00116 virtual ~OSoundCard(); 00117 00118 bool hasMixer() const { return _audio; }; 00119 bool hasAudio() const { return _mixer; }; 00120 00121 OAudioInterface* audio() const { return _audio; }; 00122 OMixerInterface* mixer() const { return _mixer; }; 00123 00124 protected: 00125 OAudioInterface* _audio; 00126 OMixerInterface* _mixer; 00127 00128 private: 00129 void init(); 00130 private: 00131 class Private; 00132 Private *d; 00133 }; 00134 00135 /*====================================================================================== 00136 * OAudioInterface 00137 *======================================================================================*/ 00138 00139 class OAudioInterface : public QObject 00140 { 00141 Q_OBJECT 00142 00143 public: 00148 OAudioInterface( QObject* parent, const char* name ); 00152 virtual ~OAudioInterface(); 00153 00154 protected: 00155 const int _sfd; 00156 00157 private: 00158 void init(); 00159 private: 00160 class Private; 00161 Private *d; 00162 }; 00163 00164 00165 /*====================================================================================== 00166 * OMixerInterface 00167 *======================================================================================*/ 00168 00169 class OMixerInterface : public QObject 00170 { 00171 Q_OBJECT 00172 00173 public: 00174 00175 typedef QMap<QString,int>::ConstIterator ChannelIterator; 00176 00181 OMixerInterface( QObject* parent, const char* name ); 00185 virtual ~OMixerInterface(); 00186 00190 QStringList allChannels() const; 00194 QStringList recChannels() const; 00198 QStringList playChannels() const; 00202 bool hasMultipleRecording() const; 00206 bool hasChannel( const QString& channel ) const; 00210 bool isStereo( const QString& channel ) const; 00214 bool isRecordable( const QString& channel ) const; 00219 void setVolume( const QString& channel, int left, int right = -1 ); 00224 int volume( const QString& channel ) const; 00225 00226 protected: 00227 int _fd; 00228 int _capmask; 00229 int _devmask; 00230 int _recmask; 00231 int _stmask; 00232 QMap<QString,int> _channels; 00233 00234 private: 00235 void init(); 00236 private: 00237 class Private; 00238 Private *d; 00239 }; 00240 00241 } 00242 } 00243 00244 #endif // OSOUNDSYSTEM_H
1.4.2