static bool isHiddenAudioOutputDevice(const GlobalConfig *config, int i) { Q_ASSERT(config); if (!config->hideAdvancedDevices()) return false; AudioOutputDevice ad = AudioOutputDevice::fromIndex(i); const QVariant var = ad.property("isAdvanced"); return (var.isValid() && var.toBool()); }
/** * Same as Create(), but this method won't check whether it is allowed to * create an instance of the given driver on its own. This method is * usually called by host plugins (e.g. VST, AU, DSSI, LV2) to actually * create their respective audio output devices for the sampler. Usually * one shouldn't call this method directly, but call Create() instead. */ AudioOutputDevice* AudioOutputDeviceFactory::CreatePrivate(String DriverName, std::map<String,String> Parameters) throw (Exception) { if (!InnerFactories.count(DriverName)) throw Exception("There is no audio output driver '" + DriverName + "'."); // let's see if we need to create parameters std::map<String,DeviceCreationParameter*> thisDeviceParams; DeviceParameterFactory* pParamFactory = ParameterFactories[DriverName]; if (pParamFactory) { thisDeviceParams = pParamFactory->CreateAllParams(Parameters); } else { // no parameters are registered by the driver. Throw if any parameters were specified. if (Parameters.size() != 0) throw Exception("Driver '" + DriverName + "' does not have any parameters."); } // get a free device id int iDeviceId = -1; for (int i = 0; i >= 0; i++) { // seek for a free place starting from the beginning if (!mAudioOutputDevices[i]) { iDeviceId = i; mAudioOutputDevices.erase(i); break; } } if (iDeviceId < 0) throw Exception("Could not retrieve free device ID!"); // now create the device using those parameters AudioOutputDevice* pDevice = InnerFactories[DriverName]->Create(thisDeviceParams); pDevice->setDeviceId(iDeviceId); // now attach all parameters to the newely created device. for (std::map<String,DeviceCreationParameter*>::iterator iter = thisDeviceParams.begin(); iter != thisDeviceParams.end(); iter++) { iter->second->Attach(pDevice); } // add new audio device to the audio device list mAudioOutputDevices[iDeviceId] = pDevice; return pDevice; }
bool AudioOutput::setOutputDevice(const AudioOutputDevice &newDevice) { return setOutputDevice(newDevice.index()); }
bool AudioOutput::setOutputDevice(const AudioOutputDevice & newDevice) { //stub implementation return setOutputDevice(newDevice.index()); }
void AudioOutputCoreConfBridge::on_property_changed (std::string key, GmConfEntry *entry) { std::string name; std::string file_name; bool enabled; if (key == AUDIO_DEVICES_KEY "output_device") { std::vector <AudioOutputDevice> devices; bool found = false; gchar* value = gm_conf_entry_get_string (entry); audiooutput_core.get_devices (devices); if (value != NULL) for (std::vector<AudioOutputDevice>::iterator it = devices.begin (); it < devices.end (); it++) if ((*it).GetString () == value) { found = true; break; } AudioOutputDevice device; if (found) device.SetFromString (value); else { if (!devices.empty()) device.SetFromString (devices.begin ()->GetString ()); else { // if there is no audio device / ptlib plugin, use fallback device below g_warning ("Error: no audio device found!"); device.type == ""; } } g_free (value); if ( (device.type == "" ) || (device.source == "") || (device.name == "" ) ) { PTRACE(1, "AudioOutputCore\tTried to set malformed device"); device.type = AUDIO_OUTPUT_FALLBACK_DEVICE_TYPE; device.source = AUDIO_OUTPUT_FALLBACK_DEVICE_SOURCE; device.name = AUDIO_OUTPUT_FALLBACK_DEVICE_NAME; } PTRACE(4, "AudioOutputCoreConfBridge\tSet device to " << device.source << "/" << device.name); audiooutput_core.set_device (primary, device); } if (key == SOUND_EVENTS_KEY "output_device") { PTRACE(4, "AudioOutputCoreConfBridge\tUpdating device"); AudioOutputDevice device; gchar* audio_device = gm_conf_entry_get_string (entry); if (audio_device == NULL) PTRACE(1, "AudioOutputCoreConfBridge\t" << AUDIO_DEVICES_KEY "output_device" << " is NULL"); else { device.SetFromString(audio_device); g_free (audio_device); } if ( (device.type == "") || (device.source == "") || (device.name == "") ) { PTRACE(1, "AudioOutputCore\tTried to set malformed device"); device.type = AUDIO_OUTPUT_FALLBACK_DEVICE_TYPE; device.source = AUDIO_OUTPUT_FALLBACK_DEVICE_SOURCE; device.name = AUDIO_OUTPUT_FALLBACK_DEVICE_NAME; } audiooutput_core.set_device (secondary, device); } if ( (key == SOUND_EVENTS_KEY "busy_tone_sound") || (key == SOUND_EVENTS_KEY "enable_busy_tone_sound") ) { gchar *c_file_name = NULL; c_file_name = gm_conf_get_string (SOUND_EVENTS_KEY "busy_tone_sound"); if (c_file_name == NULL) { PTRACE(1, "AudioOutputCoreConfBridge\t" << SOUND_EVENTS_KEY "busy_tone_sound" << " is NULL"); return; } name = "busy_tone_sound"; file_name = c_file_name; g_free (c_file_name); enabled = gm_conf_get_bool (SOUND_EVENTS_KEY "enable_busy_tone_sound"); audiooutput_core.map_event (name, file_name, primary, enabled); } if ( (key == SOUND_EVENTS_KEY "incoming_call_sound") || (key == SOUND_EVENTS_KEY "enable_incoming_call_sound") ) { gchar *c_file_name = NULL; c_file_name = gm_conf_get_string (SOUND_EVENTS_KEY "incoming_call_sound"); if (c_file_name == NULL) { PTRACE(1, "AudioOutputCoreConfBridge\t" << SOUND_EVENTS_KEY "incoming_call_sound" << " is NULL"); return; } name = "incoming_call_sound"; file_name = c_file_name; g_free (c_file_name); enabled = gm_conf_get_bool (SOUND_EVENTS_KEY "enable_incoming_call_sound"); audiooutput_core.map_event (name, file_name, secondary, enabled); } if ( (key == SOUND_EVENTS_KEY "new_message_sound") || (key == SOUND_EVENTS_KEY "enable_new_message_sound") ) { gchar *c_file_name = NULL; c_file_name = gm_conf_get_string (SOUND_EVENTS_KEY "new_message_sound"); if (c_file_name == NULL) { PTRACE(1, "AudioOutputCoreConfBridge\t" << SOUND_EVENTS_KEY "new_message_sound" << " is NULL"); return; } name = "new_message_sound"; file_name = c_file_name; g_free (c_file_name); enabled = gm_conf_get_bool (SOUND_EVENTS_KEY "enable_new_message_sound"); audiooutput_core.map_event (name, file_name, secondary, enabled); } if ( (key == SOUND_EVENTS_KEY "new_voicemail_sound") || (key == SOUND_EVENTS_KEY "enable_new_voicemail_sound") ) { gchar *c_file_name = NULL; c_file_name = gm_conf_get_string (SOUND_EVENTS_KEY "new_voicemail_sound"); if (c_file_name == NULL) { PTRACE(1, "AudioOutputCoreConfBridge\t" << SOUND_EVENTS_KEY "new_voicemail_sound" << " is NULL"); return; } name = "new_voicemail_sound"; file_name = c_file_name; g_free (c_file_name); enabled = gm_conf_get_bool (SOUND_EVENTS_KEY "enable_new_voicemail_sound"); audiooutput_core.map_event (name, file_name, secondary, enabled); } if ( (key == SOUND_EVENTS_KEY "ring_tone_sound") || (key == SOUND_EVENTS_KEY "enable_ring_tone_sound") ) { gchar *c_file_name = NULL; c_file_name = gm_conf_get_string (SOUND_EVENTS_KEY "ring_tone_sound"); if (c_file_name == NULL) { PTRACE(1, "AudioOutputCoreConfBridge\t" << SOUND_EVENTS_KEY "ring_tone_sound" << " is NULL"); return; } name = "ring_tone_sound"; file_name = c_file_name; g_free (c_file_name); enabled = gm_conf_get_bool (SOUND_EVENTS_KEY "enable_ring_tone_sound"); audiooutput_core.map_event (name, file_name, primary, enabled); } }
void AudioOutputDeviceTest::sensibleValues() { AudioOutputDevice a; QCOMPARE(a.isValid(), false); AudioOutputDevice b(a); QCOMPARE(b.isValid(), false); b = a; QCOMPARE(b.isValid(), false); if (Factory::backendName() == QLatin1String("Fake")) { AudioOutputDevice c = AudioOutputDevice::fromIndex(10000); QCOMPARE(c.isValid(), true); QCOMPARE(c.index(), 10000); QCOMPARE(c.name(), QString("internal Soundcard")); QCOMPARE(c.description(), QString()); b = AudioOutputDevice::fromIndex(10001); QCOMPARE(b.isValid(), true); QCOMPARE(b.index(), 10001); QCOMPARE(b.name(), QString("USB Soundcard")); QCOMPARE(b.description(), QString()); QCOMPARE(a.isValid(), false); a = c; QCOMPARE(a, c); QCOMPARE(a.isValid(), true); QCOMPARE(a.index(), 10000); QCOMPARE(a.name(), QString("internal Soundcard")); QCOMPARE(a.description(), QString()); } else { // TODO check for ALSA devices listed by libaudiodevicelist } }