本文整理汇总了C++中Mixer::isValid方法的典型用法代码示例。如果您正苦于以下问题:C++ Mixer::isValid方法的具体用法?C++ Mixer::isValid怎么用?C++ Mixer::isValid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mixer
的用法示例。
在下文中一共展示了Mixer::isValid方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: initMixer
/**
* Scan for Mixers in the System. This is the method that implicitely fills the
* list of Mixer's, which is accesible via the static Mixer::mixer() method.
* @par mixers The list where to add the found Mixers. This parameter is superfluous
* nowadays, as it is now really trivial to get it - just call the static
* Mixer::mixer() method.
* @par multiDriverMode Whether the Mixer scan should try more all backendends.
* 'true' means to scan all backends. 'false' means: After scanning the
* current backend the next backend is only scanned if no Mixers were found yet.
*/
void MixerToolBox::initMixer(QPtrList<Mixer> &mixers, bool multiDriverMode, QString& ref_hwInfoString)
{
//kdDebug(67100) << "IN MixerToolBox::initMixer()"<<endl;
// Find all mixers and initalize them
QMap<QString,int> mixerNums;
int drvNum = Mixer::numDrivers();
int driverWithMixer = -1;
bool multipleDriversActive = false;
QString driverInfo = "";
QString driverInfoUsed = "";
for( int drv1=0; drv1<drvNum; drv1++ )
{
QString driverName = Mixer::driverName(drv1);
if ( driverInfo.length() > 0 )
driverInfo += " + ";
driverInfo += driverName;
}
/* Run a loop over all drivers. The loop will terminate after the first driver which
has mixers. And here is the reason:
- If you run ALSA with ALSA-OSS-Emulation enabled, mixers will show up twice: once
as native ALSA mixer, once as OSS mixer (emulated by ALSA). This is bad and WILL
confuse users. So it is a design decision that we can compile in multiple drivers
but we can run only one driver.
- For special usage scenarios, people will still want to run both drivers at the
same time. We allow them to hack their Config-File, where they can enable a
multi-driver mode.
- Another remark: For KMix3.0 or so, we should allow multiple-driver, for allowing
addition of special-use drivers, e.g. an Jack-Mixer-Backend, or a CD-Rom volume Backend.
*/
bool autodetectionFinished = false;
for( int drv=0; drv<drvNum; drv++ )
{
QString driverName = Mixer::driverName(drv);
if ( autodetectionFinished ) {
// sane exit from loop
break;
}
bool drvInfoAppended = false;
// The "19" below is just a "silly" number:
// (Old: The loop will break as soon as an error is detected - e.g. on 3rd loop when 2 soundcards are installed)
// New: We don't try be that clever anymore. We now blindly scan 20 cards, as the clever
// approach doesn't work for the one or other user.
int devNumMax = 19;
for( int dev=0; dev<=devNumMax; dev++ )
{
Mixer *mixer = new Mixer( drv, dev );
if ( mixer->isValid() ) {
mixer->open();
mixers.append( mixer );
// Count mixer nums for every mixer name to identify mixers with equal names.
// This is for creating persistent (reusable) primary keys, which can safely
// be referenced (especially for config file access, so it is meant to be persistent!).
mixerNums[mixer->mixerName()]++;
// Create a useful PK
/* As we use "::" and ":" as separators, the parts %1,%2 and %3 may not
* contain it.
* %1, the driver name is from the KMix backends, it does not contain colons.
* %2, the mixer name, is typically coming from an OS driver. It could contain colons.
* %3, the mixer number, is a number: it does not contain colons.
*/
QString mixerName = mixer->mixerName();
mixerName.replace(":","_");
QString primaryKeyOfMixer = QString("%1::%2:%3")
.arg(driverName)
.arg(mixerName)
.arg(mixerNums[mixer->mixerName()]);
// The following 3 replaces are for not messing up the config file
primaryKeyOfMixer.replace("]","_");
primaryKeyOfMixer.replace("[","_"); // not strictly neccesary, but lets play safe
primaryKeyOfMixer.replace(" ","_");
primaryKeyOfMixer.replace("=","_");
mixer->setID(primaryKeyOfMixer);
} // valid
else
{
delete mixer;
mixer = 0;
} // invalid
/* Lets decide if we the autoprobing shall continue: */
if ( multiDriverMode ) {
//.........这里部分代码省略.........