static AudioDevice getAudioDeviceFromComboBox(QComboBox* comboBox, const std::list<AudioDevice> deviceList) { std::string concatString = comboBox->itemData(comboBox->currentIndex()).toString().toStdString(); for (std::list<AudioDevice>::const_iterator it = deviceList.begin(); it != deviceList.end(); ++it) { if (it->getData().toString() == concatString) { return *it; } } return AudioDevice(); }
void DeviceList::Initalise_device_List() { _audio_devices.clear(); //boost::thread agentPollSevice(boost::bind(&DeviceList::wate_for_AgentReplys, this)); AudioDevice ad1 = AudioDevice(); ad1.Set_IP("192.168.1.1"); _audio_devices[0] = ad1; _audio_devices[1] = ad1; }
std::list<AudioDevice> AudioDeviceManager::getInputDeviceList() { RecursiveMutex::ScopedLock scopedLock(_mutex); std::list<AudioDevice> listDevices; StringList devices = getMixerDeviceList(MIXERLINE_TARGETTYPE_WAVEIN); for (unsigned i = 0; i < devices.size(); i++) { StringList data; data += devices[i]; data += String::fromNumber(Win32AudioDeviceId::getWaveInDeviceId(devices[i])); data += EnumDeviceType::toString(EnumDeviceType::DeviceTypeWaveIn); listDevices.push_back(AudioDevice(data)); } return listDevices; }
/** * Updates the current list of active devices */ void DeviceManager::updateDeviceList() { //fetch list of current devices GstElement *audioSink= createAudioSink(); QList<QByteArray> list; if (audioSink) { if (!PulseSupport::getInstance()->isActive()) { // If we're using pulse, the PulseSupport class takes care of things for us. list = GstHelper::extractProperties(audioSink, "device"); list.prepend("default"); } for (int i = 0 ; i < list.size() ; ++i) { QByteArray gstId = list.at(i); if (deviceId(gstId) == -1) { // This is a new device, add it m_audioDeviceList.append(AudioDevice(this, gstId)); emit deviceAdded(deviceId(gstId)); m_backend->logMessage(QString("Found new audio device %0").arg(QString::fromUtf8(gstId)), Backend::Debug, this); } } if (list.size() < m_audioDeviceList.size()) { //a device was removed for (int i = m_audioDeviceList.size() -1 ; i >= 0 ; --i) { QByteArray currId = m_audioDeviceList[i].gstId; bool found = false; for (int k = list.size() -1 ; k >= 0 ; --k) { if (currId == list[k]) { found = true; break; } } if (!found) { m_backend->logMessage(QString("Audio device lost %0").arg(QString::fromUtf8(currId)), Backend::Debug, this); emit deviceRemoved(deviceId(currId)); m_audioDeviceList.removeAt(i); } } } } gst_element_set_state (audioSink, GST_STATE_NULL); gst_object_unref (audioSink); }
AudioDevice AudioDeviceManager::getDefaultInputDevice() { RecursiveMutex::ScopedLock scopedLock(_mutex); std::string defaultDeviceName(getDefaultDeviceFromRegistry(RECORD_DEVICE_REGISTRY_KEY)); if (defaultDeviceName.empty()) { WAVEINCAPSA incaps; //We didn't find the default record audio device using the registry //Try using the device id = 0 => should be the default record audio device if (MMSYSERR_NOERROR == ::waveInGetDevCapsA(DEFAULT_DEVICE_ID, &incaps, sizeof(WAVEINCAPSA))) { char * deviceName = strdup(incaps.szPname); defaultDeviceName = deviceName; } } StringList data; data += defaultDeviceName; data += String::fromNumber(Win32AudioDeviceId::getWaveInDeviceId(defaultDeviceName)); data += EnumDeviceType::toString(EnumDeviceType::DeviceTypeWaveIn); return AudioDevice(data); }
AudioDevice AudioDeviceManager::getDefaultOutputDevice() { RecursiveMutex::ScopedLock scopedLock(_mutex); std::string defaultDeviceName(getDefaultDeviceFromRegistry(PLAYBACK_DEVICE_REGISTRY_KEY)); if (defaultDeviceName.empty()) { WAVEOUTCAPSA outcaps; //We didn't find the default playback audio device using the registry //Try using the device id = 0 => should be the default playback audio device if (MMSYSERR_NOERROR == ::waveOutGetDevCapsA(DEFAULT_DEVICE_ID, &outcaps, sizeof(WAVEOUTCAPSA))) { char * deviceName = strdup(outcaps.szPname); defaultDeviceName = deviceName; } } StringList data; data += defaultDeviceName; data += String::fromNumber(Win32AudioDeviceId::getWaveOutDeviceId(defaultDeviceName)); data += EnumDeviceType::toString(EnumDeviceType::DeviceTypeMasterVolume); return AudioDevice(data); }
AudioDevice AudioDevice::defaultOutput() { initDevices(); return AudioDevice(Pa_GetDefaultOutputDevice()); }
void QtWizardAudio::readConfig() { Config & config = ConfigManager::getInstance().getCurrentConfig(); //inputDeviceList _ui->inputDeviceComboBox->clear(); #ifdef OS_LINUX bool savedSettingsFound = false; AudioDevice tmpDev(config.getAudioInputDeviceId()); #endif std::list<AudioDevice> inputDeviceList = AudioDeviceManager::getInstance().getInputDeviceList(); for (std::list<AudioDevice>::const_iterator it = inputDeviceList.begin(); it != inputDeviceList.end(); ++it) { _ui->inputDeviceComboBox->addItem( QString::fromUtf8((*it).getName().c_str()), QString::fromStdString((*it).getData().toString()) ); #ifdef OS_LINUX if ((*it).getData() == tmpDev.getData()) { savedSettingsFound = true; } #endif } #ifdef OS_LINUX if (!savedSettingsFound) { _ui->outputDeviceComboBox->addItem( QString::fromUtf8(tmpDev.getName().c_str()), QString::fromStdString(tmpDev.getData().toString()) ); } #endif QString currentInputDeviceId = QString::fromUtf8(config.getAudioInputDeviceId().toString().c_str()); _ui->inputDeviceComboBox->setCurrentIndex( _ui->inputDeviceComboBox->findData(currentInputDeviceId) ); //// //outputDeviceList _ui->outputDeviceComboBox->clear(); #ifdef OS_LINUX savedSettingsFound = false; tmpDev = AudioDevice(config.getAudioOutputDeviceId()); #endif std::list<AudioDevice> outputDeviceList = AudioDeviceManager::getInstance().getOutputDeviceList(); for (std::list<AudioDevice>::const_iterator it = outputDeviceList.begin(); it != outputDeviceList.end(); ++it) { _ui->outputDeviceComboBox->addItem( QString::fromUtf8((*it).getName().c_str()), QString::fromStdString((*it).getData().toString()) ); #ifdef OS_LINUX if ((*it).getData() == tmpDev.getData()) { savedSettingsFound = true; } #endif } #ifdef OS_LINUX if (!savedSettingsFound) { _ui->outputDeviceComboBox->addItem( QString::fromUtf8(tmpDev.getName().c_str()), QString::fromStdString(tmpDev.getData().toString()) ); } #endif QString currentOutputDeviceId = QString::fromUtf8(config.getAudioOutputDeviceId().toString().c_str()); _ui->outputDeviceComboBox->setCurrentIndex( _ui->outputDeviceComboBox->findData(currentOutputDeviceId) ); //// //ringingDeviceList = outputDeviceList _ui->ringingDeviceComboBox->clear(); #ifdef OS_LINUX savedSettingsFound = false; tmpDev = AudioDevice(config.getAudioOutputDeviceId()); #endif for (std::list<AudioDevice>::const_iterator it = outputDeviceList.begin(); it != outputDeviceList.end(); ++it) { _ui->ringingDeviceComboBox->addItem( QString::fromUtf8((*it).getName().c_str()), QString::fromStdString((*it).getData().toString()) ); #ifdef OS_LINUX if ((*it).getData() == tmpDev.getData()) { savedSettingsFound = true; } #endif } #ifdef OS_LINUX if (!savedSettingsFound) { _ui->ringingDeviceComboBox->addItem( QString::fromUtf8(tmpDev.getName().c_str()), QString::fromStdString(tmpDev.getData().toString()) ); } #endif QString currentRingerDeviceId = QString::fromUtf8(config.getAudioRingerDeviceId().toString().c_str()); _ui->ringingDeviceComboBox->setCurrentIndex( _ui->ringingDeviceComboBox->findData(currentRingerDeviceId) ); //// }