本文整理汇总了C++中QAudioDeviceInfo::isNull方法的典型用法代码示例。如果您正苦于以下问题:C++ QAudioDeviceInfo::isNull方法的具体用法?C++ QAudioDeviceInfo::isNull怎么用?C++ QAudioDeviceInfo::isNull使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QAudioDeviceInfo
的用法示例。
在下文中一共展示了QAudioDeviceInfo::isNull方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
const QAudioDeviceInfo inputDevice = QAudioDeviceInfo::defaultInputDevice();
if (inputDevice.isNull()) {
QMessageBox::warning(nullptr, "audio",
"There is no audio input device available.");
return -1;
}
Widget w(inputDevice);
w.show();
return a.exec();
}
示例2: start
void MainWindow::start()
{
if (m_audio_lib)
{
stopRecord();
buttonrecord->setEnabled(false);
m_audio_lib->stop();
#ifdef Q_OS_WIN
if (m_loopback)
m_loopback->deleteLater();
#endif
return;
}
QByteArray password = linepassword->text().toLatin1();
if (comboboxaudioinput->count() == 0)
{
msgBoxCritical("Error", "No input device found", this);
return;
}
bool ok = false;
int port = lineport->text().toInt(&ok);
if (!ok || port < 1 || port > 65535)
{
msgBoxCritical("Error", "Port must have a value between 1 and 65535,\n"
"including these values", this);
return;
}
int max_connections = linemaxconnections->text().toInt(&ok);
if (!ok || max_connections < 1)
{
msgBoxCritical("Error", "Enter a value equal or higher to 1 on maximum connections", this);
return;
}
m_audio_lib = new AudioStreamingLibCore(this);
StreamingInfo info;
info.setWorkMode(StreamingInfo::StreamingWorkMode::BroadcastServer);
info.setEncryptionEnabled(!password.isEmpty());
info.setGetAudioEnabled(true);
info.setListenAudioInputEnabled(boxlisteninput->isChecked());
info.setNegotiationString(QByteArray("BroadcastTCPDemo"));
info.setID(lineid->text().trimmed());
QAudioDeviceInfo inputdevinfo = comboboxaudioinput->currentData().value<QAudioDeviceInfo>();
if (inputdevinfo.isNull())
{
#ifdef Q_OS_WIN
if (comboboxaudioinput->currentData(Qt::UserRole + 1).value<int>() == AudioInputInfo::Loopback)
{
m_loopback = new QWinLoopback(this);
connect(m_loopback, &QObject::destroyed, this, [=]
{
if (isVisible())
m_buffer.clear();
});
bool started = m_loopback->start();
if (!started)
return;
info.setInputDeviceType(StreamingInfo::AudioDeviceType::CustomAudioDevice);
info.setCallBackEnabled(true);
QAudioFormat format = m_loopback->format();
connect(m_loopback, &QWinLoopback::readyRead, this, &MainWindow::loopbackdata);
connect(m_audio_lib, &AudioStreamingLibCore::inputData, this, &MainWindow::process);
info.setInputAudioFormat(format);
}
else //FFMPEG
#endif
{
QAudioFormat format;
format.setSampleSize(32);
format.setSampleRate(48000);
format.setChannelCount(2);
format.setSampleType(QAudioFormat::Float);
format.setByteOrder(QAudioFormat::LittleEndian);
info.setInputDeviceType(StreamingInfo::AudioDeviceType::CustomAudioDevice);
info.setCallBackEnabled(true);
connect(m_audio_lib, &AudioStreamingLibCore::inputData, this, &MainWindow::process);
//.........这里部分代码省略.........