- if (IsOpen())
- {
- // returns true when something changed
- if (m_commands->PersistConfiguration(configuration))
- {
- {
- CLockObject lock(m_mutex);
- uint64_t iNow = GetTimeMs();
- if (iNow - m_iLastEepromWrite < CEC_ADAPTER_EEPROM_WRITE_INTERVAL)
- {
- // if there was more than 1 write within the last 30 seconds, schedule another one
- if (m_iScheduleEepromWrite == 0)
- m_iScheduleEepromWrite = m_iLastEepromWrite + CEC_ADAPTER_EEPROM_WRITE_INTERVAL;
- return true;
- }
- else
- {
- m_iLastEepromWrite = iNow;
- }
- }
-
- if (!m_commands->WriteEEPROM())
- {
- // write failed, retry later
- CLockObject lock(m_mutex);
- m_iScheduleEepromWrite = GetTimeMs() + CEC_ADAPTER_EEPROM_WRITE_RETRY;
- }
- }
- }
- return IsOpen() ? m_commands->PersistConfiguration(configuration) : false;