summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2005-01-30 19:00:38 (UTC)
committer mickeyl <mickeyl>2005-01-30 19:00:38 (UTC)
commitc3b5d1ebb51848a679f96ac3bb1c8acb1b06138e (patch) (unidiff)
tree9ac1d1281b3bdd92d1975bdc7756e89ebe730f34
parent271dd6ba75ddfba5ac4345e9d74db4dbb2b7c971 (diff)
downloadopie-c3b5d1ebb51848a679f96ac3bb1c8acb1b06138e.zip
opie-c3b5d1ebb51848a679f96ac3bb1c8acb1b06138e.tar.gz
opie-c3b5d1ebb51848a679f96ac3bb1c8acb1b06138e.tar.bz2
improve mixer code
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--examples/opiemm/osoundsystemdemo/osoundsystemdemo.cpp14
-rw-r--r--libopie2/config.in12
-rw-r--r--libopie2/opiemm/osoundsystem.cpp120
-rw-r--r--libopie2/opiemm/osoundsystem.h17
4 files changed, 72 insertions, 91 deletions
diff --git a/examples/opiemm/osoundsystemdemo/osoundsystemdemo.cpp b/examples/opiemm/osoundsystemdemo/osoundsystemdemo.cpp
index f74a1b9..b18d719 100644
--- a/examples/opiemm/osoundsystemdemo/osoundsystemdemo.cpp
+++ b/examples/opiemm/osoundsystemdemo/osoundsystemdemo.cpp
@@ -50,4 +50,4 @@ int main( int argc, char** argv )
50 OSoundCard* card = it.current(); 50 OSoundCard* card = it.current();
51
52 OMixerInterface* mixer = card->mixer(); 51 OMixerInterface* mixer = card->mixer();
52 odebug << "This device " << ( mixer->hasMultipleRecording() ? "does" : "does not" ) << " feature multiple recording sources." << oendl;
53 53
@@ -58,5 +58,11 @@ int main( int argc, char** argv )
58 bool stereo = mixer->isStereo( *it ); 58 bool stereo = mixer->isStereo( *it );
59 odebug << "OSSDEMO: Mixer has channel " << *it << ( stereo ? "[stereo]" : "[mono]" ) << oendl; 59 bool recsrc = mixer->isRecordable( *it );
60 odebug << "OSSDEMO: +--- volume " << ( mixer->volume( *it ) & 0xff ) 60 QString line = "OSSDEMO: Mixer has channel " + *it + " ";
61 << " (left) | " << ( mixer->volume( *it ) >> 8 ) << " (right)" << oendl; 61 line = line.leftJustify( 50 ) + ( stereo ? "[stereo]" : "[mono]" );
62 line = line.leftJustify( 60 ) + ( recsrc ? "[recsrc]" : "[ ]" );
63 line = line.leftJustify( 70 );
64 line += " [ " + QString::number( mixer->volume( *it ) & 0xff ).rightJustify( 3 );
65 if ( stereo ) line += " | " + QString::number( mixer->volume( *it ) >> 8 ).rightJustify( 3 );
66 line += " ]";
67 odebug << line << oendl;
62 } 68 }
diff --git a/libopie2/config.in b/libopie2/config.in
deleted file mode 100644
index 5f1bed3..0000000
--- a/libopie2/config.in
+++ b/dev/null
@@ -1,12 +0,0 @@
1#menu "libopie2"
2 comment ""
3 source libopie2/opiecore/config.in
4 source libopie2/opiedb/config.in
5 source libopie2/opienet/config.in
6 source libopie2/opiepim/config.in
7 source libopie2/opieui/config.in
8 source libopie2/opiemm/config.in
9 source libopie2/opiesecurity/config.in
10 comment ""
11#endmenu
12
diff --git a/libopie2/opiemm/osoundsystem.cpp b/libopie2/opiemm/osoundsystem.cpp
index 09fd28f..6c03203 100644
--- a/libopie2/opiemm/osoundsystem.cpp
+++ b/libopie2/opiemm/osoundsystem.cpp
@@ -2,4 +2,3 @@
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3 3              (C) 2003-2005 Michael 'Mickey' Lauer <mickey@Vanille.de>
4              (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
5 =. 4 =.
@@ -42,2 +41,4 @@
42 41
42static const char* device_label[] = SOUND_DEVICE_LABELS;
43static int max_device_nr = sizeof device_label / sizeof (const char*);
43 44
@@ -66,3 +67,2 @@ void OSoundSystem::synchronize()
66 67
67
68 /* 68 /*
@@ -178,3 +178,3 @@ void OAudioInterface::init()
178OMixerInterface::OMixerInterface( QObject* parent, const char* name ) 178OMixerInterface::OMixerInterface( QObject* parent, const char* name )
179 :QObject( parent, name ) 179 :QObject( parent, name ), _devmask( 0 ), _recmask( 0 ), _stmask( 0 )
180{ 180{
@@ -201,57 +201,29 @@ void OMixerInterface::init()
201 // construct the device capabilities 201 // construct the device capabilities
202 int devmask = 0; 202 if ( ioctl( _fd, SOUND_MIXER_READ_CAPS, &_capmask ) != -1 )
203 if ( ioctl( _fd, SOUND_MIXER_READ_DEVMASK, &devmask ) != -1 ) 203 {
204 { 204 odebug << "OMixerInterface::init() - capmask = " << _capmask << oendl;
205 if ( devmask & ( 1 << SOUND_MIXER_VOLUME ) ) _channels.insert( "PlayVolume", SOUND_MIXER_VOLUME ); 205 }
206 if ( devmask & ( 1 << SOUND_MIXER_BASS ) ) _channels.insert( "PlayBass", SOUND_MIXER_BASS ); 206 if ( ioctl( _fd, SOUND_MIXER_READ_DEVMASK, &_devmask ) != -1 )
207 if ( devmask & ( 1 << SOUND_MIXER_TREBLE ) ) _channels.insert( "PlayTreble", SOUND_MIXER_TREBLE ); 207 {
208 if ( devmask & ( 1 << SOUND_MIXER_SYNTH ) ) _channels.insert( "PlaySynth", SOUND_MIXER_SYNTH ); 208 odebug << "OMixerInterface::init() - devmask = " << _devmask << oendl;
209 if ( devmask & ( 1 << SOUND_MIXER_PCM ) ) _channels.insert( "PlayPCM", SOUND_MIXER_PCM ); 209 }
210 if ( devmask & ( 1 << SOUND_MIXER_SPEAKER ) ) _channels.insert( "PlaySpeaker", SOUND_MIXER_SPEAKER ); 210 if ( ioctl( _fd, SOUND_MIXER_READ_RECMASK, &_recmask ) != -1 )
211 if ( devmask & ( 1 << SOUND_MIXER_LINE ) ) _channels.insert( "PlayLine", SOUND_MIXER_LINE ); 211 {
212 if ( devmask & ( 1 << SOUND_MIXER_MIC ) ) _channels.insert( "PlayMic", SOUND_MIXER_MIC ); 212 odebug << "OMixerInterface::init() - recmask = " << _recmask << oendl;
213 if ( devmask & ( 1 << SOUND_MIXER_CD ) ) _channels.insert( "PlayCD", SOUND_MIXER_CD ); 213 }
214 if ( devmask & ( 1 << SOUND_MIXER_IMIX ) ) _channels.insert( "PlayInputMix", SOUND_MIXER_IMIX ); 214 if ( ioctl( _fd, SOUND_MIXER_READ_STEREODEVS, &_stmask ) != -1 )
215 if ( devmask & ( 1 << SOUND_MIXER_ALTPCM ) ) _channels.insert( "PlayAltPCM", SOUND_MIXER_ALTPCM ); 215 {
216 if ( devmask & ( 1 << SOUND_MIXER_RECLEV ) ) _channels.insert( "PlayRecord", SOUND_MIXER_RECLEV ); 216 odebug << "OMixerInterface::init() - stereomask = " << _stmask << oendl;
217 if ( devmask & ( 1 << SOUND_MIXER_IGAIN ) ) _channels.insert( "PlayInputGain", SOUND_MIXER_IGAIN ); 217 }
218 if ( devmask & ( 1 << SOUND_MIXER_OGAIN ) ) _channels.insert( "PlayOutputGain", SOUND_MIXER_OGAIN ); 218 for ( int i = 0; i < max_device_nr; ++i )
219 //odebug << "devmask available and constructed." << oendl; 219 {
220 } 220 if ( _devmask & ( 1 << i ) )
221 221 {
222 devmask = 0; 222 _channels.insert( QString( device_label[i] ).stripWhiteSpace(), i );
223 if ( ioctl( _fd, SOUND_MIXER_READ_RECMASK, &devmask ) != -1 ) 223 odebug << "OMixerInterface::init() - channel '" << device_label[i] << "'" << oendl;
224 { 224 }
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 );
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 );
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 );
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 );
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 );
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 );
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 );
239 //odebug << "recmask available and constructed." << oendl;
240 }
241
242 devmask = 0;
243 if ( ioctl( _fd, SOUND_MIXER_READ_STEREODEVS, &devmask ) != -1 )
244 {
245 odebug << "stereomask = " << devmask << oendl;
246 }
247
248/* ChannelIterator it;
249 for ( it = _channels.begin(); it != _channels.end(); ++it )
250 {
251 odebug << "Channel " << it.key() << " available (bit " << it.data() << ")" << oendl;
252 odebug << " +--- Volume: " << volume( it.key() ) & 0xff << " | " << volume( it.key() ) >> 8 << "" << oendl;
253 } 225 }
254*/
255} 226}
256 227
228
257QStringList OMixerInterface::allChannels() const 229QStringList OMixerInterface::allChannels() const
@@ -262,4 +234,3 @@ QStringList OMixerInterface::allChannels() const
262 { 234 {
263 channels += it.key(); 235 channels += it++.key();
264 it++;
265 } 236 }
@@ -271,4 +242,9 @@ QStringList OMixerInterface::recChannels() const
271{ 242{
272 owarn << "NYI" << oendl; 243 ChannelIterator it = _channels.begin();
273 return QStringList(); 244 QStringList channels;
245 while ( it != _channels.end() )
246 {
247 if ( _recmask & ( 1 << _channels[it.key()] ) ) channels += it++.key();
248 }
249 return channels;
274} 250}
@@ -278,4 +254,9 @@ QStringList OMixerInterface::playChannels() const
278{ 254{
279 owarn << "NYI" << oendl; 255 return allChannels();
280 return QStringList(); 256}
257
258
259bool OMixerInterface::hasMultipleRecording() const
260{
261 return !( _capmask & SOUND_CAP_EXCL_INPUT );
281} 262}
@@ -291,12 +272,9 @@ bool OMixerInterface::isStereo( const QString& channel ) const
291{ 272{
292 bool result = false; 273 return _channels.contains( channel ) && ( _stmask & ( 1 << _channels[channel] ) );
293 if ( _channels.contains( channel ) )
294 {
295 int devmask = 0;
296 if ( ioctl( _fd, SOUND_MIXER_READ_STEREODEVS, &devmask ) != -1 )
297 {
298 result = devmask & ( 1 << _channels[channel] );
299 } 274 }
300 } 275
301 return result; 276
277bool OMixerInterface::isRecordable( const QString& channel ) const
278{
279 return _channels.contains( channel ) && ( _recmask & ( 1 << _channels[channel] ) );
302} 280}
diff --git a/libopie2/opiemm/osoundsystem.h b/libopie2/opiemm/osoundsystem.h
index ac7a5a7..cce90c0 100644
--- a/libopie2/opiemm/osoundsystem.h
+++ b/libopie2/opiemm/osoundsystem.h
@@ -2,4 +2,3 @@
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3 3              (C) 2003-2005 Michael 'Mickey' Lauer <mickey@Vanille.de>
4              (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
5 =. 4 =.
@@ -200,3 +199,6 @@ class OMixerInterface : public QObject
200 QStringList playChannels() const; 199 QStringList playChannels() const;
201 200 /**
201 * @returns true, if the device features multiple recording sources.
202 */
203 bool hasMultipleRecording() const;
202 /** 204 /**
@@ -209,3 +211,6 @@ class OMixerInterface : public QObject
209 bool isStereo( const QString& channel ) const; 211 bool isStereo( const QString& channel ) const;
210 212 /**
213 * @returns tru, if @a channel is a possible recording source.
214 */
215 bool isRecordable( const QString& channel ) const;
211 /** 216 /**
@@ -223,2 +228,6 @@ class OMixerInterface : public QObject
223 int _fd; 228 int _fd;
229 int _capmask;
230 int _devmask;
231 int _recmask;
232 int _stmask;
224 QMap<QString, int> _channels; 233 QMap<QString, int> _channels;