summaryrefslogtreecommitdiff
path: root/libopie2
Unidiff
Diffstat (limited to 'libopie2') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/examples/opiemm/osoundsystemdemo/osoundsystemdemo.cpp3
-rw-r--r--libopie2/opiemm/osoundsystem.cpp25
-rw-r--r--libopie2/opiemm/osoundsystem.h6
3 files changed, 30 insertions, 4 deletions
diff --git a/libopie2/examples/opiemm/osoundsystemdemo/osoundsystemdemo.cpp b/libopie2/examples/opiemm/osoundsystemdemo/osoundsystemdemo.cpp
index b522441..f74a1b9 100644
--- a/libopie2/examples/opiemm/osoundsystemdemo/osoundsystemdemo.cpp
+++ b/libopie2/examples/opiemm/osoundsystemdemo/osoundsystemdemo.cpp
@@ -54,9 +54,10 @@ int main( int argc, char** argv )
54 QStringList channels = mixer->allChannels(); 54 QStringList channels = mixer->allChannels();
55 55
56 for ( QStringList::Iterator it = channels.begin(); it != channels.end(); ++it ) 56 for ( QStringList::Iterator it = channels.begin(); it != channels.end(); ++it )
57 { 57 {
58 odebug << "OSSDEMO: Mixer has channel " << *it << "" << oendl; 58 bool stereo = mixer->isStereo( *it );
59 odebug << "OSSDEMO: Mixer has channel " << *it << ( stereo ? "[stereo]" : "[mono]" ) << oendl;
59 odebug << "OSSDEMO: +--- volume " << ( mixer->volume( *it ) & 0xff ) 60 odebug << "OSSDEMO: +--- volume " << ( mixer->volume( *it ) & 0xff )
60 << " (left) | " << ( mixer->volume( *it ) >> 8 ) << " (right)" << oendl; 61 << " (left) | " << ( mixer->volume( *it ) >> 8 ) << " (right)" << oendl;
61 } 62 }
62 63
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
@@ -193,9 +193,9 @@ void OMixerInterface::init()
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
@@ -238,8 +238,14 @@ void OMixerInterface::init()
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;
@@ -274,14 +280,29 @@ QStringList OMixerInterface::playChannels() const
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;
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
@@ -201,9 +201,13 @@ class OMixerInterface : public QObject
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.