summaryrefslogtreecommitdiff
authorwimpie <wimpie>2005-01-04 01:31:53 (UTC)
committer wimpie <wimpie>2005-01-04 01:31:53 (UTC)
commit42638ffd708a5236ad9a1f06a40b9d8b7919277c (patch) (unidiff)
tree687d61c6e2d5ddd20dff42cf6e1b18afbe81633f
parent0f3d74b472817e6b4f9d80adc122281b84629c1f (diff)
downloadopie-42638ffd708a5236ad9a1f06a40b9d8b7919277c.zip
opie-42638ffd708a5236ad9a1f06a40b9d8b7919277c.tar.gz
opie-42638ffd708a5236ad9a1f06a40b9d8b7919277c.tar.bz2
CONTROL file :changed VERSION string
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiemm/libopiemm2.control2
-rw-r--r--libopie2/opiemm/osoundsystem.cpp2
-rw-r--r--libopie2/opiemm/osoundsystem.h1
3 files changed, 1 insertions, 4 deletions
diff --git a/libopie2/opiemm/libopiemm2.control b/libopie2/opiemm/libopiemm2.control
index d0f34a8..0dd2df2 100644
--- a/libopie2/opiemm/libopiemm2.control
+++ b/libopie2/opiemm/libopiemm2.control
@@ -1,10 +1,10 @@
1Package: libopiemm2 1Package: libopiemm2
2Files: lib/libopiemm2.so.* 2Files: lib/libopiemm2.so.*
3Priority: optional 3Priority: optional
4Section: opie/system 4Section: opie/system
5Maintainer: Opie Team <opie@handhelds.org> 5Maintainer: Opie Team <opie@handhelds.org>
6Architecture: arm 6Architecture: arm
7Version: 1.8.2-$SUB_VERSION.2 7Version: $QPE_VERSION$EXTRAVERSION
8Depends: libqpe1, libopiecore2 (1.8.2) 8Depends: libqpe1, libopiecore2 (1.8.2)
9Provides: libopiemm2 9Provides: libopiemm2
10Description: Opie library 2.0 MM 10Description: Opie library 2.0 MM
diff --git a/libopie2/opiemm/osoundsystem.cpp b/libopie2/opiemm/osoundsystem.cpp
index 17e5cb0..13b26e6 100644
--- a/libopie2/opiemm/osoundsystem.cpp
+++ b/libopie2/opiemm/osoundsystem.cpp
@@ -1,322 +1,320 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3 3
4              (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> 4              (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
5 =. 5 =.
6 .=l. 6 .=l.
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#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; 44using namespace Opie::Core;
45using namespace Opie::MM; 45using namespace Opie::MM;
46/*====================================================================================== 46/*======================================================================================
47 * OSoundSystem 47 * OSoundSystem
48 *======================================================================================*/ 48 *======================================================================================*/
49 49
50OSoundSystem* OSoundSystem::_instance = 0; 50OSoundSystem* OSoundSystem::_instance = 0;
51 51
52OSoundSystem::OSoundSystem() 52OSoundSystem::OSoundSystem()
53{ 53{
54 odebug << "OSoundSystem::OSoundSystem()" << oendl; 54 odebug << "OSoundSystem::OSoundSystem()" << oendl;
55 synchronize(); 55 synchronize();
56} 56}
57 57
58void OSoundSystem::synchronize() 58void OSoundSystem::synchronize()
59{ 59{
60 // gather available interfaces by inspecting /dev 60 // gather available interfaces by inspecting /dev
61 //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
62 //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
63 63
64 _interfaces.clear(); 64 _interfaces.clear();
65 _interfaces.insert( "soundcard", new OSoundCard( this, "soundcard" ) ); 65 _interfaces.insert( "soundcard", new OSoundCard( this, "soundcard" ) );
66 66
67 67
68 /* 68 /*
69 69
70 QString str; 70 QString str;
71 QFile f( "/dev/sound" ); 71 QFile f( "/dev/sound" );
72 bool hasFile = f.open( IO_ReadOnly ); 72 bool hasFile = f.open( IO_ReadOnly );
73 if ( !hasFile ) 73 if ( !hasFile )
74 { 74 {
75 odebug << "OSoundSystem: /dev/sound not existing. No sound devices available" << oendl; 75 odebug << "OSoundSystem: /dev/sound not existing. No sound devices available" << oendl;
76 return; 76 return;
77 } 77 }
78 QTextStream s( &f ); 78 QTextStream s( &f );
79 s.readLine(); 79 s.readLine();
80 s.readLine(); 80 s.readLine();
81 while ( !s.atEnd() ) 81 while ( !s.atEnd() )
82 { 82 {
83 s >> str; 83 s >> str;
84 str.truncate( str.find( ':' ) ); 84 str.truncate( str.find( ':' ) );
85 odebug << "OSoundSystem: found interface '" << str << "'" << oendl; 85 odebug << "OSoundSystem: found interface '" << str << "'" << oendl;
86 OAudioInterface* iface; 86 OAudioInterface* iface;
87 iface = new OAudioInterface( this, (const char*) str ); 87 iface = new OAudioInterface( this, (const char*) str );
88 88
89 _interfaces.insert( str, iface ); 89 _interfaces.insert( str, iface );
90 s.readLine(); 90 s.readLine();
91 } 91 }
92*/ 92*/
93} 93}
94 94
95 95
96int OSoundSystem::count() const 96int OSoundSystem::count() const
97{ 97{
98 return _interfaces.count(); 98 return _interfaces.count();
99} 99}
100 100
101 101
102OSoundCard* OSoundSystem::card( const QString& iface ) const 102OSoundCard* OSoundSystem::card( const QString& iface ) const
103{ 103{
104 return _interfaces[iface]; 104 return _interfaces[iface];
105} 105}
106 106
107 107
108OSoundSystem* OSoundSystem::instance() 108OSoundSystem* OSoundSystem::instance()
109{ 109{
110 if ( !_instance ) _instance = new OSoundSystem(); 110 if ( !_instance ) _instance = new OSoundSystem();
111 return _instance; 111 return _instance;
112} 112}
113 113
114 114
115OSoundSystem::CardIterator OSoundSystem::iterator() const 115OSoundSystem::CardIterator OSoundSystem::iterator() const
116{ 116{
117 return OSoundSystem::CardIterator( _interfaces ); 117 return OSoundSystem::CardIterator( _interfaces );
118} 118}
119 119
120 120
121/*====================================================================================== 121/*======================================================================================
122 * OSoundCard 122 * OSoundCard
123 *======================================================================================*/ 123 *======================================================================================*/
124 124
125OSoundCard::OSoundCard( QObject* parent, const char* name ) 125OSoundCard::OSoundCard( QObject* parent, const char* name )
126 :QObject( parent, name ), _audio( 0 ), _mixer( 0 ) 126 :QObject( parent, name ), _audio( 0 ), _mixer( 0 )
127{ 127{
128 odebug << "OSoundCard::OSoundCard()" << oendl; 128 odebug << "OSoundCard::OSoundCard()" << oendl;
129 init(); 129 init();
130} 130}
131 131
132 132
133OSoundCard::~OSoundCard() 133OSoundCard::~OSoundCard()
134{ 134{
135} 135}
136 136
137 137
138void OSoundCard::init() 138void OSoundCard::init()
139{ 139{
140#ifdef QT_QWS_DEVFS 140#ifdef QT_QWS_DEVFS
141 _audio = new OAudioInterface( this, "/dev/sound/dsp" ); 141 _audio = new OAudioInterface( this, "/dev/sound/dsp" );
142 _mixer = new OMixerInterface( this, "/dev/sound/mixer" ); 142 _mixer = new OMixerInterface( this, "/dev/sound/mixer" );
143#else 143#else
144 _audio = new OAudioInterface( this, "/dev/dsp" ); 144 _audio = new OAudioInterface( this, "/dev/dsp" );
145 _mixer = new OMixerInterface( this, "/dev/mixer" ); 145 _mixer = new OMixerInterface( this, "/dev/mixer" );
146#endif 146#endif
147} 147}
148 148
149 149
150/*====================================================================================== 150/*======================================================================================
151 * OAudioInterface 151 * OAudioInterface
152 *======================================================================================*/ 152 *======================================================================================*/
153 153
154OAudioInterface::OAudioInterface( QObject* parent, const char* name ) 154OAudioInterface::OAudioInterface( QObject* parent, const char* name )
155 :QObject( parent, name ), _sfd(0) 155 :QObject( parent, name ), _sfd(0)
156{ 156{
157 odebug << "OAudioInterface::OAudioInterface()" << oendl; 157 odebug << "OAudioInterface::OAudioInterface()" << oendl;
158 init(); 158 init();
159} 159}
160 160
161 161
162OAudioInterface::~OAudioInterface() 162OAudioInterface::~OAudioInterface()
163{ 163{
164} 164}
165 165
166 166
167void OAudioInterface::init() 167void OAudioInterface::init()
168{ 168{
169 169
170 170
171} 171}
172 172
173 173
174/*====================================================================================== 174/*======================================================================================
175 * OMixerInterface 175 * OMixerInterface
176 *======================================================================================*/ 176 *======================================================================================*/
177 177
178OMixerInterface::OMixerInterface( QObject* parent, const char* name ) 178OMixerInterface::OMixerInterface( QObject* parent, const char* name )
179 :QObject( parent, name ) 179 :QObject( parent, name )
180{ 180{
181 odebug << "OMixerInterface::OMixerInterface()" << oendl; 181 odebug << "OMixerInterface::OMixerInterface()" << oendl;
182 init(); 182 init();
183} 183}
184 184
185 185
186OMixerInterface::~OMixerInterface() 186OMixerInterface::~OMixerInterface()
187{ 187{
188} 188}
189 189
190 190
191void OMixerInterface::init() 191void OMixerInterface::init()
192{ 192{
193 // open the device 193 // open the device
194 _fd = ::open( name(), O_RDWR ); 194 _fd = ::open( name(), O_RDWR );
195 if ( _fd == -1 ) 195 if ( _fd == -1 )
196 { 196 {
197 owarn << "OMixerInterface::init(): Can't open mixer." << oendl; 197 owarn << "OMixerInterface::init(): Can't open mixer." << oendl;
198 return; 198 return;
199 } 199 }
200 200
201 // construct the device capabilities 201 // construct the device capabilities
202 int devmask = 0; 202 int devmask = 0;
203 if ( ioctl( _fd, SOUND_MIXER_READ_DEVMASK, &devmask ) != -1 ) 203 if ( ioctl( _fd, SOUND_MIXER_READ_DEVMASK, &devmask ) != -1 )
204 { 204 {
205 if ( devmask & ( 1 << SOUND_MIXER_VOLUME ) ) _channels.insert( "PlayVolume", SOUND_MIXER_VOLUME ); 205 if ( devmask & ( 1 << SOUND_MIXER_VOLUME ) ) _channels.insert( "PlayVolume", SOUND_MIXER_VOLUME );
206 if ( devmask & ( 1 << SOUND_MIXER_BASS ) ) _channels.insert( "PlayBass", SOUND_MIXER_BASS ); 206 if ( devmask & ( 1 << SOUND_MIXER_BASS ) ) _channels.insert( "PlayBass", SOUND_MIXER_BASS );
207 if ( devmask & ( 1 << SOUND_MIXER_TREBLE ) ) _channels.insert( "PlayTreble", SOUND_MIXER_TREBLE ); 207 if ( devmask & ( 1 << SOUND_MIXER_TREBLE ) ) _channels.insert( "PlayTreble", SOUND_MIXER_TREBLE );
208 if ( devmask & ( 1 << SOUND_MIXER_SYNTH ) ) _channels.insert( "PlaySynth", SOUND_MIXER_SYNTH ); 208 if ( devmask & ( 1 << SOUND_MIXER_SYNTH ) ) _channels.insert( "PlaySynth", SOUND_MIXER_SYNTH );
209 if ( devmask & ( 1 << SOUND_MIXER_PCM ) ) _channels.insert( "PlayPCM", SOUND_MIXER_PCM ); 209 if ( devmask & ( 1 << SOUND_MIXER_PCM ) ) _channels.insert( "PlayPCM", SOUND_MIXER_PCM );
210 if ( devmask & ( 1 << SOUND_MIXER_SPEAKER ) ) _channels.insert( "PlaySpeaker", SOUND_MIXER_SPEAKER ); 210 if ( devmask & ( 1 << SOUND_MIXER_SPEAKER ) ) _channels.insert( "PlaySpeaker", SOUND_MIXER_SPEAKER );
211 if ( devmask & ( 1 << SOUND_MIXER_LINE ) ) _channels.insert( "PlayLine", SOUND_MIXER_LINE ); 211 if ( devmask & ( 1 << SOUND_MIXER_LINE ) ) _channels.insert( "PlayLine", SOUND_MIXER_LINE );
212 if ( devmask & ( 1 << SOUND_MIXER_MIC ) ) _channels.insert( "PlayMic", SOUND_MIXER_MIC ); 212 if ( devmask & ( 1 << SOUND_MIXER_MIC ) ) _channels.insert( "PlayMic", SOUND_MIXER_MIC );
213 if ( devmask & ( 1 << SOUND_MIXER_CD ) ) _channels.insert( "PlayCD", SOUND_MIXER_CD ); 213 if ( devmask & ( 1 << SOUND_MIXER_CD ) ) _channels.insert( "PlayCD", SOUND_MIXER_CD );
214 if ( devmask & ( 1 << SOUND_MIXER_IMIX ) ) _channels.insert( "PlayInputMix", SOUND_MIXER_IMIX ); 214 if ( devmask & ( 1 << SOUND_MIXER_IMIX ) ) _channels.insert( "PlayInputMix", SOUND_MIXER_IMIX );
215 if ( devmask & ( 1 << SOUND_MIXER_ALTPCM ) ) _channels.insert( "PlayAltPCM", SOUND_MIXER_ALTPCM ); 215 if ( devmask & ( 1 << SOUND_MIXER_ALTPCM ) ) _channels.insert( "PlayAltPCM", SOUND_MIXER_ALTPCM );
216 if ( devmask & ( 1 << SOUND_MIXER_RECLEV ) ) _channels.insert( "PlayRecord", SOUND_MIXER_RECLEV ); 216 if ( devmask & ( 1 << SOUND_MIXER_RECLEV ) ) _channels.insert( "PlayRecord", SOUND_MIXER_RECLEV );
217 if ( devmask & ( 1 << SOUND_MIXER_IGAIN ) ) _channels.insert( "PlayInputGain", SOUND_MIXER_IGAIN ); 217 if ( devmask & ( 1 << SOUND_MIXER_IGAIN ) ) _channels.insert( "PlayInputGain", SOUND_MIXER_IGAIN );
218 if ( devmask & ( 1 << SOUND_MIXER_OGAIN ) ) _channels.insert( "PlayOutputGain", SOUND_MIXER_OGAIN ); 218 if ( devmask & ( 1 << SOUND_MIXER_OGAIN ) ) _channels.insert( "PlayOutputGain", SOUND_MIXER_OGAIN );
219 //odebug << "devmask available and constructed." << oendl; 219 //odebug << "devmask available and constructed." << oendl;
220 } 220 }
221 221
222 devmask = 0; 222 devmask = 0;
223 if ( ioctl( _fd, SOUND_MIXER_READ_RECMASK, &devmask ) != -1 ) 223 if ( ioctl( _fd, SOUND_MIXER_READ_RECMASK, &devmask ) != -1 )
224 { 224 {
225 if ( devmask & ( 1 << SOUND_MIXER_VOLUME ) ) _channels.insert( "RecVolume", SOUND_MIXER_VOLUME ); 225 if ( devmask & ( 1 << SOUND_MIXER_VOLUME ) ) _channels.insert( "RecVolume", SOUND_MIXER_VOLUME );
226 if ( devmask & ( 1 << SOUND_MIXER_BASS ) ) _channels.insert( "RecBass", SOUND_MIXER_BASS ); 226 if ( devmask & ( 1 << SOUND_MIXER_BASS ) ) _channels.insert( "RecBass", SOUND_MIXER_BASS );
227 if ( devmask & ( 1 << SOUND_MIXER_TREBLE ) ) _channels.insert( "RecTreble", SOUND_MIXER_TREBLE ); 227 if ( devmask & ( 1 << SOUND_MIXER_TREBLE ) ) _channels.insert( "RecTreble", SOUND_MIXER_TREBLE );
228 if ( devmask & ( 1 << SOUND_MIXER_SYNTH ) ) _channels.insert( "RecSynth", SOUND_MIXER_SYNTH ); 228 if ( devmask & ( 1 << SOUND_MIXER_SYNTH ) ) _channels.insert( "RecSynth", SOUND_MIXER_SYNTH );
229 if ( devmask & ( 1 << SOUND_MIXER_PCM ) ) _channels.insert( "RecPCM", SOUND_MIXER_PCM ); 229 if ( devmask & ( 1 << SOUND_MIXER_PCM ) ) _channels.insert( "RecPCM", SOUND_MIXER_PCM );
230 if ( devmask & ( 1 << SOUND_MIXER_SPEAKER ) ) _channels.insert( "RecSpeaker", SOUND_MIXER_SPEAKER ); 230 if ( devmask & ( 1 << SOUND_MIXER_SPEAKER ) ) _channels.insert( "RecSpeaker", SOUND_MIXER_SPEAKER );
231 if ( devmask & ( 1 << SOUND_MIXER_LINE ) ) _channels.insert( "RecLine", SOUND_MIXER_LINE ); 231 if ( devmask & ( 1 << SOUND_MIXER_LINE ) ) _channels.insert( "RecLine", SOUND_MIXER_LINE );
232 if ( devmask & ( 1 << SOUND_MIXER_MIC ) ) _channels.insert( "RecMic", SOUND_MIXER_MIC ); 232 if ( devmask & ( 1 << SOUND_MIXER_MIC ) ) _channels.insert( "RecMic", SOUND_MIXER_MIC );
233 if ( devmask & ( 1 << SOUND_MIXER_CD ) ) _channels.insert( "RecCD", SOUND_MIXER_CD ); 233 if ( devmask & ( 1 << SOUND_MIXER_CD ) ) _channels.insert( "RecCD", SOUND_MIXER_CD );
234 if ( devmask & ( 1 << SOUND_MIXER_IMIX ) ) _channels.insert( "RecInputMix", SOUND_MIXER_IMIX ); 234 if ( devmask & ( 1 << SOUND_MIXER_IMIX ) ) _channels.insert( "RecInputMix", SOUND_MIXER_IMIX );
235 if ( devmask & ( 1 << SOUND_MIXER_ALTPCM ) ) _channels.insert( "RecAltPCM", SOUND_MIXER_ALTPCM ); 235 if ( devmask & ( 1 << SOUND_MIXER_ALTPCM ) ) _channels.insert( "RecAltPCM", SOUND_MIXER_ALTPCM );
236 if ( devmask & ( 1 << SOUND_MIXER_RECLEV ) ) _channels.insert( "RecRecord", SOUND_MIXER_RECLEV ); 236 if ( devmask & ( 1 << SOUND_MIXER_RECLEV ) ) _channels.insert( "RecRecord", SOUND_MIXER_RECLEV );
237 if ( devmask & ( 1 << SOUND_MIXER_IGAIN ) ) _channels.insert( "RecInputGain", SOUND_MIXER_IGAIN ); 237 if ( devmask & ( 1 << SOUND_MIXER_IGAIN ) ) _channels.insert( "RecInputGain", SOUND_MIXER_IGAIN );
238 if ( devmask & ( 1 << SOUND_MIXER_OGAIN ) ) _channels.insert( "RecOutputGain", SOUND_MIXER_OGAIN ); 238 if ( devmask & ( 1 << SOUND_MIXER_OGAIN ) ) _channels.insert( "RecOutputGain", SOUND_MIXER_OGAIN );
239 //odebug << "recmask available and constructed." << oendl; 239 //odebug << "recmask available and constructed." << oendl;
240 } 240 }
241 241
242/* ChannelIterator it; 242/* ChannelIterator it;
243 for ( it = _channels.begin(); it != _channels.end(); ++it ) 243 for ( it = _channels.begin(); it != _channels.end(); ++it )
244 { 244 {
245 odebug << "Channel " << it.key() << " available (bit " << it.data() << ")" << oendl; 245 odebug << "Channel " << it.key() << " available (bit " << it.data() << ")" << oendl;
246 odebug << " +--- Volume: " << volume( it.key() ) & 0xff << " | " << volume( it.key() ) >> 8 << "" << oendl; 246 odebug << " +--- Volume: " << volume( it.key() ) & 0xff << " | " << volume( it.key() ) >> 8 << "" << oendl;
247 } 247 }
248*/ 248*/
249} 249}
250 250
251QStringList OMixerInterface::allChannels() const 251QStringList OMixerInterface::allChannels() const
252{ 252{
253 ChannelIterator it = _channels.begin(); 253 ChannelIterator it = _channels.begin();
254 QStringList channels; 254 QStringList channels;
255 while ( it != _channels.end() ) 255 while ( it != _channels.end() )
256 { 256 {
257 channels += it.key(); 257 channels += it.key();
258 it++; 258 it++;
259 } 259 }
260 return channels; 260 return channels;
261} 261}
262 262
263 263
264QStringList OMixerInterface::recChannels() const 264QStringList OMixerInterface::recChannels() const
265{ 265{
266 owarn << "NYI" << oendl; 266 owarn << "NYI" << oendl;
267 return QStringList(); 267 return QStringList();
268} 268}
269 269
270 270
271QStringList OMixerInterface::playChannels() const 271QStringList OMixerInterface::playChannels() const
272{ 272{
273 owarn << "NYI" << oendl; 273 owarn << "NYI" << oendl;
274 return QStringList(); 274 return QStringList();
275} 275}
276 276
277 277
278bool OMixerInterface::hasChannel( const QString& channel ) 278bool OMixerInterface::hasChannel( const QString& channel )
279{ 279{
280 return _channels.contains( channel ); 280 return _channels.contains( channel );
281} 281}
282 282
283 283
284void OMixerInterface::setVolume( const QString& channel, int left, int right ) 284void OMixerInterface::setVolume( const QString& channel, int left, int right )
285{ 285{
286 int volume = left; 286 int volume = left;
287 volume |= ( right == -1 ) ? left << 8 : right << 8; 287 volume |= ( right == -1 ) ? left << 8 : right << 8;
288 288
289 if ( _channels.contains( channel ) ) 289 if ( _channels.contains( channel ) )
290 { 290 {
291 int result = ioctl( _fd, MIXER_WRITE( _channels[channel] ), &volume ); 291 int result = ioctl( _fd, MIXER_WRITE( _channels[channel] ), &volume );
292 if ( result == -1 ) 292 if ( result == -1 )
293 { 293 {
294 owarn << "Can't set volume: " << strerror( errno ) << oendl; 294 owarn << "Can't set volume: " << strerror( errno ) << oendl;
295 } 295 }
296 else 296 else
297 { 297 {
298 if ( result & 0xff != left ) 298 if ( result & 0xff != left )
299 { 299 {
300 owarn << "Device adjusted volume from " << left << " to " << (result & 0xff) << oendl; 300 owarn << "Device adjusted volume from " << left << " to " << (result & 0xff) << oendl;
301 } 301 }
302 } 302 }
303 } 303 }
304} 304}
305 305
306 306
307int OMixerInterface::volume( const QString& channel ) const 307int OMixerInterface::volume( const QString& channel ) const
308{ 308{
309 int volume; 309 int volume;
310 310
311 if ( _channels.contains( channel ) ) 311 if ( _channels.contains( channel ) )
312 { 312 {
313 if ( ioctl( _fd, MIXER_READ( _channels[channel] ), &volume ) == -1 ) 313 if ( ioctl( _fd, MIXER_READ( _channels[channel] ), &volume ) == -1 )
314 { 314 {
315 owarn << "Can't get volume: " << strerror( errno ) << oendl; 315 owarn << "Can't get volume: " << strerror( errno ) << oendl;
316 } 316 }
317 else return volume; 317 else return volume;
318 } 318 }
319 return -1; 319 return -1;
320} 320}
321
322
diff --git a/libopie2/opiemm/osoundsystem.h b/libopie2/opiemm/osoundsystem.h
index 3c3b622..bd69114 100644
--- a/libopie2/opiemm/osoundsystem.h
+++ b/libopie2/opiemm/osoundsystem.h
@@ -1,233 +1,232 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3 3
4              (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> 4              (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
5 =. 5 =.
6 .=l. 6 .=l.
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 { 39namespace Opie {
40namespace MM { 40namespace MM {
41 41
42class OAudioInterface; 42class OAudioInterface;
43class OMixerInterface; 43class OMixerInterface;
44class OSoundCard; 44class OSoundCard;
45 45
46/*====================================================================================== 46/*======================================================================================
47 * OSoundSystem 47 * OSoundSystem
48 *======================================================================================*/ 48 *======================================================================================*/
49 49
50/** 50/**
51 * @brief A container class for all audio interfaces 51 * @brief A container class for all audio interfaces
52 * 52 *
53 * 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.
54 * 54 *
55 * @author Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> 55 * @author Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
56 */ 56 */
57class OSoundSystem : public QObject 57class OSoundSystem : public QObject
58{ 58{
59 Q_OBJECT 59 Q_OBJECT
60 60
61 public: 61 public:
62 typedef QDict<OSoundCard> CardMap; 62 typedef QDict<OSoundCard> CardMap;
63 typedef QDictIterator<OSoundCard> CardIterator; 63 typedef QDictIterator<OSoundCard> CardIterator;
64 64
65 public: 65 public:
66 /** 66 /**
67 * @returns the number of available interfaces 67 * @returns the number of available interfaces
68 */ 68 */
69 int count() const; 69 int count() const;
70 /** 70 /**
71 * @returns a pointer to the (one and only) @ref ONetwork instance. 71 * @returns a pointer to the (one and only) @ref ONetwork instance.
72 */ 72 */
73 static OSoundSystem* instance(); 73 static OSoundSystem* instance();
74 /** 74 /**
75 * @returns an iterator usable for iterating through all network interfaces. 75 * @returns an iterator usable for iterating through all network interfaces.
76 */ 76 */
77 CardIterator iterator() const; 77 CardIterator iterator() const;
78 /** 78 /**
79 * @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
80 * @see OAudioInterface 80 * @see OAudioInterface
81 */ 81 */
82 OSoundCard* card( const QString& interface ) const; 82 OSoundCard* card( const QString& interface ) const;
83 /** 83 /**
84 * @internal Rebuild the internal interface database 84 * @internal Rebuild the internal interface database
85 * @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,
86 * e.g. after issuing a cardctl insert 86 * e.g. after issuing a cardctl insert
87 */ 87 */
88 void synchronize(); 88 void synchronize();
89 89
90 protected: 90 protected:
91 OSoundSystem(); 91 OSoundSystem();
92 92
93 private: 93 private:
94 static OSoundSystem* _instance; 94 static OSoundSystem* _instance;
95 CardMap _interfaces; 95 CardMap _interfaces;
96 class Private; 96 class Private;
97 Private *d; 97 Private *d;
98}; 98};
99 99
100 100
101/*====================================================================================== 101/*======================================================================================
102 * OSoundCard 102 * OSoundCard
103 *======================================================================================*/ 103 *======================================================================================*/
104 104
105class OSoundCard : public QObject 105class OSoundCard : public QObject
106{ 106{
107 Q_OBJECT 107 Q_OBJECT
108 108
109 public: 109 public:
110 /** 110 /**
111 * Constructor. Normally you don't create @ref OSoundCard objects yourself, 111 * Constructor. Normally you don't create @ref OSoundCard objects yourself,
112 * but access them via @ref OSoundSystem::card(). 112 * but access them via @ref OSoundSystem::card().
113 */ 113 */
114 OSoundCard( QObject* parent, const char* name ); 114 OSoundCard( QObject* parent, const char* name );
115 /** 115 /**
116 * Destructor. 116 * Destructor.
117 */ 117 */
118 virtual ~OSoundCard(); 118 virtual ~OSoundCard();
119 119
120 bool hasMixer() const { return _audio; }; 120 bool hasMixer() const { return _audio; };
121 bool hasAudio() const { return _mixer; }; 121 bool hasAudio() const { return _mixer; };
122 122
123 OAudioInterface* audio() const { return _audio; }; 123 OAudioInterface* audio() const { return _audio; };
124 OMixerInterface* mixer() const { return _mixer; }; 124 OMixerInterface* mixer() const { return _mixer; };
125 125
126 protected: 126 protected:
127 OAudioInterface* _audio; 127 OAudioInterface* _audio;
128 OMixerInterface* _mixer; 128 OMixerInterface* _mixer;
129 129
130 private: 130 private:
131 void init(); 131 void init();
132 private: 132 private:
133 class Private; 133 class Private;
134 Private *d; 134 Private *d;
135}; 135};
136 136
137/*====================================================================================== 137/*======================================================================================
138 * OAudioInterface 138 * OAudioInterface
139 *======================================================================================*/ 139 *======================================================================================*/
140 140
141class OAudioInterface : public QObject 141class OAudioInterface : public QObject
142{ 142{
143 Q_OBJECT 143 Q_OBJECT
144 144
145 public: 145 public:
146 /** 146 /**
147 * Constructor. Normally you don't create @ref OAudioInterface objects yourself, 147 * Constructor. Normally you don't create @ref OAudioInterface objects yourself,
148 * but access them via the @ref OSoundCard interface. 148 * but access them via the @ref OSoundCard interface.
149 */ 149 */
150 OAudioInterface( QObject* parent, const char* name ); 150 OAudioInterface( QObject* parent, const char* name );
151 /** 151 /**
152 * Destructor. 152 * Destructor.
153 */ 153 */
154 virtual ~OAudioInterface(); 154 virtual ~OAudioInterface();
155 155
156 protected: 156 protected:
157 const int _sfd; 157 const int _sfd;
158 158
159 private: 159 private:
160 void init(); 160 void init();
161 private: 161 private:
162 class Private; 162 class Private;
163 Private *d; 163 Private *d;
164}; 164};
165 165
166 166
167/*====================================================================================== 167/*======================================================================================
168 * OMixerInterface 168 * OMixerInterface
169 *======================================================================================*/ 169 *======================================================================================*/
170 170
171class OMixerInterface : public QObject 171class OMixerInterface : public QObject
172{ 172{
173 Q_OBJECT 173 Q_OBJECT
174 174
175 public: 175 public:
176 176
177 typedef QMap<QString,int>::ConstIterator ChannelIterator; 177 typedef QMap<QString,int>::ConstIterator ChannelIterator;
178 178
179 /** 179 /**
180 * Constructor. Normally you don't create @ref OMixerInterface objects yourself, 180 * Constructor. Normally you don't create @ref OMixerInterface objects yourself,
181 * but access them via the @ref OSoundCard interface. 181 * but access them via the @ref OSoundCard interface.
182 */ 182 */
183 OMixerInterface( QObject* parent, const char* name ); 183 OMixerInterface( QObject* parent, const char* name );
184 /** 184 /**
185 * Destructor. 185 * Destructor.
186 */ 186 */
187 virtual ~OMixerInterface(); 187 virtual ~OMixerInterface();
188 188
189 /** 189 /**
190 * @returns all available channels. 190 * @returns all available channels.
191 */ 191 */
192 QStringList allChannels() const; 192 QStringList allChannels() const;
193 /** 193 /**
194 * @returns recordable channels. 194 * @returns recordable channels.
195 */ 195 */
196 QStringList recChannels() const; 196 QStringList recChannels() const;
197 /** 197 /**
198 * @returns playable channels. 198 * @returns playable channels.
199 */ 199 */
200 QStringList playChannels() const; 200 QStringList playChannels() const;
201 201
202 /** 202 /**
203 * @returns true, if @a channel exists. 203 * @returns true, if @a channel exists.
204 */ 204 */
205 bool hasChannel( const QString& channel ); 205 bool hasChannel( const QString& channel );
206 206
207 /** 207 /**
208 * Set the @a left and @a right volumes for @a channel. 208 * Set the @a left and @a right volumes for @a channel.
209 * 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.
210 */ 210 */
211 void setVolume( const QString& channel, int left, int right = -1 ); 211 void setVolume( const QString& channel, int left, int right = -1 );
212 /** 212 /**
213 * @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.
214 * @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.
215 */ 215 */
216 int volume( const QString& channel ) const; 216 int volume( const QString& channel ) const;
217 217
218 protected: 218 protected:
219 int _fd; 219 int _fd;
220 QMap<QString, int> _channels; 220 QMap<QString, int> _channels;
221 221
222 private: 222 private:
223 void init(); 223 void init();
224 private: 224 private:
225 class Private; 225 class Private;
226 Private *d; 226 Private *d;
227}; 227};
228 228
229} 229}
230} 230}
231 231
232#endif // OSOUNDSYSTEM_H 232#endif // OSOUNDSYSTEM_H
233