bool CUPowerSyscall::PumpPowerEvents(IPowerEventsCallback *callback) { bool result = false; if (m_connection) { dbus_connection_read_write(m_connection, 0); DBusMessagePtr msg(dbus_connection_pop_message(m_connection)); if (msg) { result = true; if (dbus_message_is_signal(msg.get(), "org.freedesktop.UPower", "Sleeping")) callback->OnSleep(); else if (dbus_message_is_signal(msg.get(), "org.freedesktop.UPower", "Resuming")) callback->OnWake(); else if (dbus_message_is_signal(msg.get(), "org.freedesktop.UPower", "Changed")) { bool lowBattery = m_lowBattery; UpdateCapabilities(); if (m_lowBattery && !lowBattery) callback->OnLowBattery(); } else CLog::Log(LOGDEBUG, "UPower: Received an unknown signal %s", dbus_message_get_member(msg.get())); } } return result; }
void AudioConfigSettings::AudioAdvanced() { QString out = m_OutputDevice->getValue(); bool invalid = false; AudioOutputSettings settings; if (!audiodevs.contains(out)) { invalid = true; } else { settings = audiodevs.value(out).settings; } AudioAdvancedSettingsGroup audiosettings(invalid || (settings.canLPCM() && settings.canPassthrough() >= 0)); if (audiosettings.exec() == kDialogCodeAccepted) { AudioRescan(); UpdateCapabilities(QString::null); } }
CUPowerSyscall::CUPowerSyscall() { CLog::Log(LOGINFO, "Selected UPower as PowerSyscall"); m_lowBattery = false; //! @todo do not use dbus_connection_pop_message() that requires the use of a //! private connection if (m_connection.Connect(DBUS_BUS_SYSTEM, true)) { dbus_connection_set_exit_on_disconnect(m_connection, false); CDBusError error; dbus_bus_add_match(m_connection, "type='signal',interface='org.freedesktop.UPower'", error); dbus_connection_flush(m_connection); if (error) { error.Log("UPower: Failed to attach to signal"); m_connection.Destroy(); } } m_CanPowerdown = false; m_CanReboot = false; UpdateCapabilities(); EnumeratePowerSources(); }
void AudioConfigSettings::AudioAdvanced() { QString out = m_OutputDevice->getValue(); bool invalid = false; AudioOutputSettings settings; if (!audiodevs.contains(out)) { invalid = true; } else { settings = audiodevs.value(out).settings; } bool LPCM1 = settings.canFeature(FEATURE_LPCM) && gCoreContext->GetNumSetting("StereoPCM", false); AudioAdvancedSettingsGroup audiosettings(invalid || (settings.canPassthrough() >= 0)); if (audiosettings.exec() == kDialogCodeAccepted) { // Rescan audio list to check of override digital device AudioRescan(); bool LPCM2 = settings.canFeature(FEATURE_LPCM) && gCoreContext->GetNumSetting("StereoPCM", false); // restore speakers configure only of StereoPCM has changed and // we have LPCM capabilities UpdateCapabilities(QString::null, LPCM1 != LPCM2); } }
void AudioSetupWizard::toggleSpeakers(void) { if (m_testThread) { m_testThread->cancel(); m_testThread->wait(); delete m_testThread; m_testThread = NULL; m_testSpeakerButton->SetText(tr("Test Speakers")); return; } AudioOutputSettings settings = UpdateCapabilities(false); QString out = m_audioDeviceButtonList->GetItemCurrent()->GetText(); int channels = qVariantValue<int> (m_speakerNumberButtonList->GetItemCurrent()->GetData()); m_testThread = new AudioTestThread(this, out, out, channels, settings, false); if (!m_testThread->result().isEmpty()) { QString msg = QObject::tr("Audio device is invalid or not useable."); MythPopupBox::showOkPopup( GetMythMainWindow(), QObject::tr("Warning"), msg); delete m_testThread; m_testThread = NULL; } else { m_testThread->start(); m_testSpeakerButton->SetText(tr("Stop Speaker Test")); } }
CUPowerSyscall::CUPowerSyscall() { CLog::Log(LOGINFO, "Selected UPower as PowerSyscall"); m_lowBattery = false; dbus_error_init (&m_error); // TODO: do not use dbus_connection_pop_message() that requires the use of a // private connection m_connection = dbus_bus_get_private(DBUS_BUS_SYSTEM, &m_error); if (m_connection) { dbus_connection_set_exit_on_disconnect(m_connection, false); dbus_bus_add_match(m_connection, "type='signal',interface='org.freedesktop.UPower'", &m_error); dbus_connection_flush(m_connection); } if (dbus_error_is_set(&m_error)) { CLog::Log(LOGERROR, "UPower: Failed to attach to signal %s", m_error.message); dbus_connection_close(m_connection); dbus_connection_unref(m_connection); m_connection = NULL; } m_CanPowerdown = false; m_CanReboot = false; UpdateCapabilities(); EnumeratePowerSources(); }
void AudioSetupWizard::Init(void) { QString current = gCoreContext->GetSetting(QString("AudioOutputDevice")); bool found = false; if (!current.isEmpty()) { for (AudioOutput::ADCVect::const_iterator it = m_outputlist->begin(); it != m_outputlist->end(); ++it) { if (it->name == current) { found = true; break; } } if (!found) { AudioOutput::AudioDeviceConfig *adc = AudioOutput::GetAudioDeviceConfig(current, current, true); if (adc->settings.IsInvalid()) { LOG(VB_GENERAL, LOG_ERR, QString("Audio device %1 isn't usable") .arg(current)); } else { // only insert the device if it is valid m_outputlist->insert(0, *adc); } delete adc; } } for (AudioOutput::ADCVect::const_iterator it = m_outputlist->begin(); it != m_outputlist->end(); ++it) { QString name = it->name; MythUIButtonListItem *output = new MythUIButtonListItem(m_audioDeviceButtonList, name); output->SetData(name); } if (found) { m_audioDeviceButtonList->SetValueByData(qVariantFromValue(current)); } m_maxspeakers = gCoreContext->GetNumSetting("MaxChannels", 2); m_lastAudioDevice = m_audioDeviceButtonList->GetItemCurrent()->GetText(); // Update list for default audio device UpdateCapabilities(); connect(m_ac3Check, SIGNAL(valueChanged()), SLOT(UpdateCapabilitiesAC3())); connect(m_audioDeviceButtonList, SIGNAL(itemSelected(MythUIButtonListItem*)), SLOT(UpdateCapabilities(MythUIButtonListItem*))); }
AudioOutputSettings AudioSetupWizard::UpdateCapabilities( MythUIButtonListItem* item) { bool restore = false; if (item) { restore = item->GetText() != m_lastAudioDevice; m_lastAudioDevice = item->GetText(); } return UpdateCapabilities(restore); }
void AudioConfigSettings::StartAudioTest() { AudioOutputSettings settings = UpdateCapabilities(QString::null, false, false); QString out = m_OutputDevice->getValue(); QString passthrough = gCoreContext->GetNumSetting("PassThruDeviceOverride", false) ? gCoreContext->GetSetting("PassThruOutputDevice") : QString::null; int channels = m_MaxAudioChannels->getValue().toInt(); AudioTestGroup audiotest(out, passthrough, channels, settings); audiotest.exec(); }
void AudioConfigSettings::AudioRescan() { if (!slotlock.tryLock()) return; QVector<AudioOutput::AudioDeviceConfig>* list = AudioOutput::GetOutputList(); QVector<AudioOutput::AudioDeviceConfig>::const_iterator it; audiodevs.clear(); for (it = list->begin(); it != list->end(); it++) audiodevs.insert(it->name, *it); devices = *list; delete list; QString name = m_OutputDevice->getValue(); if (!audiodevs.contains(name)) { // Scan for possible custom entry that isn't in the list AudioOutput::AudioDeviceConfig *adc = AudioOutput::GetAudioDeviceConfig(name, name, true); if (adc->settings.IsInvalid()) { QString msg = name + QObject::tr(" is invalid or not useable."); MythPopupBox::showOkPopup( GetMythMainWindow(), QObject::tr("Warning"), msg); LOG(VB_GENERAL, LOG_ERR, QString("Audio device %1 isn't usable") .arg(name)); } audiodevs.insert(name, *adc); devices.append(*adc); delete adc; } m_OutputDevice->AudioRescan(); if (!CheckPassthrough()) { QString msg =QObject::tr("Passthrough device is invalid or not useable." " Check configuration in Advanced Settings:") + gCoreContext->GetSetting("PassThruOutputDevice"); MythPopupBox::showOkPopup( GetMythMainWindow(), QObject::tr("Warning"), msg); LOG(VB_GENERAL, LOG_ERR, QString("Audio device %1 isn't usable") .arg(name)); } slotlock.unlock(); UpdateCapabilities(QString::null); }
AudioOutputSettings AudioSetupWizard::UpdateCapabilitiesAC3(void) { return UpdateCapabilities(false, true); }
AudioOutputSettings AudioConfigSettings::UpdateCapabilitiesAC3(void) { return UpdateCapabilities(QString::null, false, true); }
CSystemdUPowerSyscall::CSystemdUPowerSyscall() { UpdateCapabilities(); }