summaryrefslogtreecommitdiff
path: root/libopie2/opiemm/osoundsystem.cpp
Unidiff
Diffstat (limited to 'libopie2/opiemm/osoundsystem.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiemm/osoundsystem.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/libopie2/opiemm/osoundsystem.cpp b/libopie2/opiemm/osoundsystem.cpp
index 2b17230..763ff65 100644
--- a/libopie2/opiemm/osoundsystem.cpp
+++ b/libopie2/opiemm/osoundsystem.cpp
@@ -61,49 +61,49 @@ void OSoundSystem::synchronize()
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{
@@ -216,76 +216,78 @@ void OMixerInterface::init()
216 216
217 devmask = 0; 217 devmask = 0;
218 if ( ioctl( _fd, SOUND_MIXER_READ_RECMASK, &devmask ) != -1 ) 218 if ( ioctl( _fd, SOUND_MIXER_READ_RECMASK, &devmask ) != -1 )
219 { 219 {
220 if ( devmask & ( 1 << SOUND_MIXER_VOLUME ) ) _channels.insert( "RecVolume", SOUND_MIXER_VOLUME ); 220 if ( devmask & ( 1 << SOUND_MIXER_VOLUME ) ) _channels.insert( "RecVolume", SOUND_MIXER_VOLUME );
221 if ( devmask & ( 1 << SOUND_MIXER_BASS ) ) _channels.insert( "RecBass", SOUND_MIXER_BASS ); 221 if ( devmask & ( 1 << SOUND_MIXER_BASS ) ) _channels.insert( "RecBass", SOUND_MIXER_BASS );
222 if ( devmask & ( 1 << SOUND_MIXER_TREBLE ) ) _channels.insert( "RecTreble", SOUND_MIXER_TREBLE ); 222 if ( devmask & ( 1 << SOUND_MIXER_TREBLE ) ) _channels.insert( "RecTreble", SOUND_MIXER_TREBLE );
223 if ( devmask & ( 1 << SOUND_MIXER_SYNTH ) ) _channels.insert( "RecSynth", SOUND_MIXER_SYNTH ); 223 if ( devmask & ( 1 << SOUND_MIXER_SYNTH ) ) _channels.insert( "RecSynth", SOUND_MIXER_SYNTH );
224 if ( devmask & ( 1 << SOUND_MIXER_PCM ) ) _channels.insert( "RecPCM", SOUND_MIXER_PCM ); 224 if ( devmask & ( 1 << SOUND_MIXER_PCM ) ) _channels.insert( "RecPCM", SOUND_MIXER_PCM );
225 if ( devmask & ( 1 << SOUND_MIXER_SPEAKER ) ) _channels.insert( "RecSpeaker", SOUND_MIXER_SPEAKER ); 225 if ( devmask & ( 1 << SOUND_MIXER_SPEAKER ) ) _channels.insert( "RecSpeaker", SOUND_MIXER_SPEAKER );
226 if ( devmask & ( 1 << SOUND_MIXER_LINE ) ) _channels.insert( "RecLine", SOUND_MIXER_LINE ); 226 if ( devmask & ( 1 << SOUND_MIXER_LINE ) ) _channels.insert( "RecLine", SOUND_MIXER_LINE );
227 if ( devmask & ( 1 << SOUND_MIXER_MIC ) ) _channels.insert( "RecMic", SOUND_MIXER_MIC ); 227 if ( devmask & ( 1 << SOUND_MIXER_MIC ) ) _channels.insert( "RecMic", SOUND_MIXER_MIC );
228 if ( devmask & ( 1 << SOUND_MIXER_CD ) ) _channels.insert( "RecCD", SOUND_MIXER_CD ); 228 if ( devmask & ( 1 << SOUND_MIXER_CD ) ) _channels.insert( "RecCD", SOUND_MIXER_CD );
229 if ( devmask & ( 1 << SOUND_MIXER_IMIX ) ) _channels.insert( "RecInputMix", SOUND_MIXER_IMIX ); 229 if ( devmask & ( 1 << SOUND_MIXER_IMIX ) ) _channels.insert( "RecInputMix", SOUND_MIXER_IMIX );
230 if ( devmask & ( 1 << SOUND_MIXER_ALTPCM ) ) _channels.insert( "RecAltPCM", SOUND_MIXER_ALTPCM ); 230 if ( devmask & ( 1 << SOUND_MIXER_ALTPCM ) ) _channels.insert( "RecAltPCM", SOUND_MIXER_ALTPCM );
231 if ( devmask & ( 1 << SOUND_MIXER_RECLEV ) ) _channels.insert( "RecRecord", SOUND_MIXER_RECLEV ); 231 if ( devmask & ( 1 << SOUND_MIXER_RECLEV ) ) _channels.insert( "RecRecord", SOUND_MIXER_RECLEV );
232 if ( devmask & ( 1 << SOUND_MIXER_IGAIN ) ) _channels.insert( "RecInputGain", SOUND_MIXER_IGAIN ); 232 if ( devmask & ( 1 << SOUND_MIXER_IGAIN ) ) _channels.insert( "RecInputGain", SOUND_MIXER_IGAIN );
233 if ( devmask & ( 1 << SOUND_MIXER_OGAIN ) ) _channels.insert( "RecOutputGain", SOUND_MIXER_OGAIN ); 233 if ( devmask & ( 1 << SOUND_MIXER_OGAIN ) ) _channels.insert( "RecOutputGain", SOUND_MIXER_OGAIN );
234 //odebug << "recmask available and constructed." << oendl; 234 //odebug << "recmask available and constructed." << oendl;
235 } 235 }
236 236
237/* ChannelIterator it; 237/* ChannelIterator it;
238 for ( it = _channels.begin(); it != _channels.end(); ++it ) 238 for ( it = _channels.begin(); it != _channels.end(); ++it )
239 { 239 {
240 odebug << "Channel " << it.key() << " available (bit " << it.data() << ")" << oendl; 240 odebug << "Channel " << it.key() << " available (bit " << it.data() << ")" << oendl;
241 odebug << " +--- Volume: " << volume( it.key() ) & 0xff << " | " << volume( it.key() ) >> 8 << "" << oendl; 241 odebug << " +--- Volume: " << volume( it.key() ) & 0xff << " | " << volume( it.key() ) >> 8 << "" << oendl;
242 } 242 }
243*/ 243*/
244} 244}
245 245
246QStringList OMixerInterface::allChannels() const 246QStringList OMixerInterface::allChannels() const
247{ 247{
248 ChannelIterator it = _channels.begin(); 248 ChannelIterator it = _channels.begin();
249 QStringList channels; 249 QStringList channels;
250 while ( it != _channels.end() ) 250 while ( it != _channels.end() )
251 { 251 {
252 channels += it.key(); 252 channels += it.key();
253 it++; 253 it++;
254 } 254 }
255 return channels; 255 return channels;
256} 256}
257 257
258 258
259QStringList OMixerInterface::recChannels() const 259QStringList OMixerInterface::recChannels() const
260{ 260{
261 owarn << "NYI" << oendl; 261 owarn << "NYI" << oendl;
262 return QStringList();
262} 263}
263 264
264 265
265QStringList OMixerInterface::playChannels() const 266QStringList OMixerInterface::playChannels() const
266{ 267{
267 owarn << "NYI" << oendl; 268 owarn << "NYI" << oendl;
269 return QStringList();
268} 270}
269 271
270 272
271bool OMixerInterface::hasChannel( const QString& channel ) 273bool OMixerInterface::hasChannel( const QString& channel )
272{ 274{
273 return _channels.contains( channel ); 275 return _channels.contains( channel );
274} 276}
275 277
276 278
277void OMixerInterface::setVolume( const QString& channel, int left, int right ) 279void OMixerInterface::setVolume( const QString& channel, int left, int right )
278{ 280{
279 int volume = left; 281 int volume = left;
280 volume |= ( right == -1 ) ? left << 8 : right << 8; 282 volume |= ( right == -1 ) ? left << 8 : right << 8;
281 283
282 if ( _channels.contains( channel ) ) 284 if ( _channels.contains( channel ) )
283 { 285 {
284 int result = ioctl( _fd, MIXER_WRITE( _channels[channel] ), &volume ); 286 int result = ioctl( _fd, MIXER_WRITE( _channels[channel] ), &volume );
285 if ( result == -1 ) 287 if ( result == -1 )
286 { 288 {
287 owarn << "Can't set volume: " << strerror( errno ) << oendl; 289 owarn << "Can't set volume: " << strerror( errno ) << oendl;
288 } 290 }
289 else 291 else
290 { 292 {
291 if ( result & 0xff != left ) 293 if ( result & 0xff != left )