summaryrefslogtreecommitdiff
path: root/libopie2/opiemm
Unidiff
Diffstat (limited to 'libopie2/opiemm') (more/less context) (show whitespace changes)
-rw-r--r--libopie2/opiemm/osoundsystem.cpp25
-rw-r--r--libopie2/opiemm/osoundsystem.h6
2 files changed, 28 insertions, 3 deletions
diff --git a/libopie2/opiemm/osoundsystem.cpp b/libopie2/opiemm/osoundsystem.cpp
index 13b26e6..09fd28f 100644
--- a/libopie2/opiemm/osoundsystem.cpp
+++ b/libopie2/opiemm/osoundsystem.cpp
@@ -185,25 +185,25 @@ OMixerInterface::OMixerInterface( QObject* parent, const char* name )
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 " << name() << 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 );
@@ -230,24 +230,30 @@ void OMixerInterface::init()
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 devmask = 0;
243 if ( ioctl( _fd, SOUND_MIXER_READ_STEREODEVS, &devmask ) != -1 )
244 {
245 odebug << "stereomask = " << devmask << oendl;
246 }
247
242/* ChannelIterator it; 248/* ChannelIterator it;
243 for ( it = _channels.begin(); it != _channels.end(); ++it ) 249 for ( it = _channels.begin(); it != _channels.end(); ++it )
244 { 250 {
245 odebug << "Channel " << it.key() << " available (bit " << it.data() << ")" << oendl; 251 odebug << "Channel " << it.key() << " available (bit " << it.data() << ")" << oendl;
246 odebug << " +--- Volume: " << volume( it.key() ) & 0xff << " | " << volume( it.key() ) >> 8 << "" << oendl; 252 odebug << " +--- Volume: " << volume( it.key() ) & 0xff << " | " << volume( it.key() ) >> 8 << "" << oendl;
247 } 253 }
248*/ 254*/
249} 255}
250 256
251QStringList OMixerInterface::allChannels() const 257QStringList OMixerInterface::allChannels() const
252{ 258{
253 ChannelIterator it = _channels.begin(); 259 ChannelIterator it = _channels.begin();
@@ -266,30 +272,45 @@ QStringList OMixerInterface::recChannels() const
266 owarn << "NYI" << oendl; 272 owarn << "NYI" << oendl;
267 return QStringList(); 273 return QStringList();
268} 274}
269 275
270 276
271QStringList OMixerInterface::playChannels() const 277QStringList OMixerInterface::playChannels() const
272{ 278{
273 owarn << "NYI" << oendl; 279 owarn << "NYI" << oendl;
274 return QStringList(); 280 return QStringList();
275} 281}
276 282
277 283
278bool OMixerInterface::hasChannel( const QString& channel ) 284bool OMixerInterface::hasChannel( const QString& channel ) const
279{ 285{
280 return _channels.contains( channel ); 286 return _channels.contains( channel );
281} 287}
282 288
283 289
290bool OMixerInterface::isStereo( const QString& channel ) const
291{
292 bool result = false;
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 }
300 }
301 return result;
302}
303
304
284void OMixerInterface::setVolume( const QString& channel, int left, int right ) 305void OMixerInterface::setVolume( const QString& channel, int left, int right )
285{ 306{
286 int volume = left; 307 int volume = left;
287 volume |= ( right == -1 ) ? left << 8 : right << 8; 308 volume |= ( right == -1 ) ? left << 8 : right << 8;
288 309
289 if ( _channels.contains( channel ) ) 310 if ( _channels.contains( channel ) )
290 { 311 {
291 int result = ioctl( _fd, MIXER_WRITE( _channels[channel] ), &volume ); 312 int result = ioctl( _fd, MIXER_WRITE( _channels[channel] ), &volume );
292 if ( result == -1 ) 313 if ( result == -1 )
293 { 314 {
294 owarn << "Can't set volume: " << strerror( errno ) << oendl; 315 owarn << "Can't set volume: " << strerror( errno ) << oendl;
295 } 316 }
diff --git a/libopie2/opiemm/osoundsystem.h b/libopie2/opiemm/osoundsystem.h
index bd69114..ac7a5a7 100644
--- a/libopie2/opiemm/osoundsystem.h
+++ b/libopie2/opiemm/osoundsystem.h
@@ -193,25 +193,29 @@ class OMixerInterface : public QObject
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 ) const;
206 /**
207 * @returns true, if @a channel is stereo.
208 */
209 bool isStereo( const QString& channel ) const;
206 210
207 /** 211 /**
208 * Set the @a left and @a right volumes for @a channel. 212 * 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. 213 * If no value for right is given, the value for left is taken for that.
210 */ 214 */
211 void setVolume( const QString& channel, int left, int right = -1 ); 215 void setVolume( const QString& channel, int left, int right = -1 );
212 /** 216 /**
213 * @returns the volume of @a channel or -1, if the channel doesn't exist. 217 * @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. 218 * @note You might want to use @ref hasChannel() to check if a channel exists.
215 */ 219 */
216 int volume( const QString& channel ) const; 220 int volume( const QString& channel ) const;
217 221