rcinput: try harder to reacquire input device

During lirc package update, the input device was sometimes lost and not
reacquired. Try to reacquire also if setKeyRepeatDelay fails.


Origin commit data
------------------
Branch: ni/coolstream
Commit: 2422cecfd1
Author: Stefan Seyfried <seife@tuxbox-git.slipkontur.de>
Date: 2018-06-24 (Sun, 24 Jun 2018)



------------------
This commit was generated by Migit
This commit is contained in:
Stefan Seyfried
2018-06-24 15:03:34 +02:00
committed by vanhofen
parent c5db7a1ce8
commit 84ef765db3

View File

@@ -1775,7 +1775,10 @@ void CRCInput::setKeyRepeatDelay(unsigned int start_ms, unsigned int repeat_ms)
_start_ms = start_ms;
_repeat_ms = repeat_ms;
}
for (std::vector<in_dev>::iterator it = indev.begin(); it != indev.end(); ++it) {
/* iterate backwards or the vector will be corrupted by the indev.erase(i) */
std::vector<in_dev>::iterator it = indev.end();
while (it != indev.begin()) {
--it;
int fd = (*it).fd;
std::string path = (*it).path;
if (path == "/tmp/neutrino.input")
@@ -1799,8 +1802,17 @@ void CRCInput::setKeyRepeatDelay(unsigned int start_ms, unsigned int repeat_ms)
* rcinput loop into accepting the key event... */
ie.value = start_ms + 10;
ie.code = REP_DELAY;
if (write(fd, &ie, sizeof(ie)) == -1)
if (write(fd, &ie, sizeof(ie)) == -1) {
if (errno == ENODEV) {
printf("[rcinput:%s] %s(fd %d) ENODEV??\n", __func__, path.c_str(), fd);
/* hot-unplugged? */
::close(fd);
it = indev.erase(it);
devinput_mtime.tv_sec = 0; /* force check */
continue;
}
printf("[rcinput:%s] %s(fd %d) write %s: %m\n", __func__, path.c_str(), fd, "REP_DELAY");
}
ie.value = repeat_ms + 10;
ie.code = REP_PERIOD;