-rw-r--r-- | libopie2/examples/opiemm/osoundsystemdemo/osoundsystemdemo.cpp | 3 | ||||
-rw-r--r-- | libopie2/opiemm/osoundsystem.cpp | 25 | ||||
-rw-r--r-- | libopie2/opiemm/osoundsystem.h | 6 |
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 @@ -56,5 +56,6 @@ int main( int argc, char** argv ) for ( QStringList::Iterator it = channels.begin(); it != channels.end(); ++it ) { - odebug << "OSSDEMO: Mixer has channel " << *it << "" << oendl; + bool stereo = mixer->isStereo( *it ); + odebug << "OSSDEMO: Mixer has channel " << *it << ( stereo ? "[stereo]" : "[mono]" ) << oendl; odebug << "OSSDEMO: +--- volume " << ( mixer->volume( *it ) & 0xff ) << " (left) | " << ( mixer->volume( *it ) >> 8 ) << " (right)" << oendl; 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 @@ -195,5 +195,5 @@ void OMixerInterface::init() if ( _fd == -1 ) { - owarn << "OMixerInterface::init(): Can't open mixer." << oendl; + owarn << "OMixerInterface::init(): Can't open mixer " << name() << oendl; return; } @@ -240,4 +240,10 @@ void OMixerInterface::init() } + devmask = 0; + if ( ioctl( _fd, SOUND_MIXER_READ_STEREODEVS, &devmask ) != -1 ) + { + odebug << "stereomask = " << devmask << oendl; + } + /* ChannelIterator it; for ( it = _channels.begin(); it != _channels.end(); ++it ) @@ -276,5 +282,5 @@ QStringList OMixerInterface::playChannels() const -bool OMixerInterface::hasChannel( const QString& channel ) +bool OMixerInterface::hasChannel( const QString& channel ) const { return _channels.contains( channel ); @@ -282,4 +288,19 @@ bool OMixerInterface::hasChannel( const QString& channel ) +bool OMixerInterface::isStereo( const QString& channel ) const +{ + bool result = false; + if ( _channels.contains( channel ) ) + { + int devmask = 0; + if ( ioctl( _fd, SOUND_MIXER_READ_STEREODEVS, &devmask ) != -1 ) + { + result = devmask & ( 1 << _channels[channel] ); + } + } + return result; +} + + void OMixerInterface::setVolume( const QString& channel, int left, int right ) { 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 @@ -203,5 +203,9 @@ class OMixerInterface : public QObject * @returns true, if @a channel exists. */ - bool hasChannel( const QString& channel ); + bool hasChannel( const QString& channel ) const; + /** + * @returns true, if @a channel is stereo. + */ + bool isStereo( const QString& channel ) const; /** |