mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-neutrino.git
synced 2025-08-28 16:01:10 +02:00
rcinput: Add exception handling for cs hd2
- Supplement to previous commit
Origin commit data
------------------
Branch: ni/coolstream
Commit: 1b79faff78
Author: Michael Liebmann <tuxcode.bbg@gmail.com>
Date: 2017-02-22 (Wed, 22 Feb 2017)
------------------
This commit was generated by Migit
This commit is contained in:
@@ -178,6 +178,27 @@ bool CRCInput::checkdev()
|
||||
bool CRCInput::checkpath(in_dev id)
|
||||
{
|
||||
for (std::vector<in_dev>::iterator it = indev.begin(); it != indev.end(); ++it) {
|
||||
#ifdef BOXMODEL_CS_HD2
|
||||
if ((id.type == DT_LNK) || ((*it).type == DT_LNK)) {
|
||||
std::string check1, check2;
|
||||
if (id.type == DT_LNK)
|
||||
check1 = readLink(id.path);
|
||||
else
|
||||
check1 = id.path;
|
||||
|
||||
if ((*it).type == DT_LNK)
|
||||
check2 = readLink((*it).path);
|
||||
else
|
||||
check2 = (*it).path;
|
||||
|
||||
if ((!check1.empty()) && (!check2.empty()) && (check1 == check2)) {
|
||||
printf("[rcinput:%s] skipping already opened %s => %s\n", __func__, id.path.c_str(), check1.c_str());
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
if ((*it).path == id.path) {
|
||||
printf("[rcinput:%s] skipping already opened %s\n", __func__, id.path.c_str());
|
||||
return true;
|
||||
@@ -186,6 +207,25 @@ bool CRCInput::checkpath(in_dev id)
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifdef BOXMODEL_CS_HD2
|
||||
bool CRCInput::checkLnkDev(std::string lnk)
|
||||
{
|
||||
static struct stat info;
|
||||
if (lstat(lnk.c_str(), &info) != -1) {
|
||||
if (S_ISLNK(info.st_mode)) {
|
||||
std::string tmp = readLink(lnk);
|
||||
if (!tmp.empty()) {
|
||||
if (lstat(tmp.c_str(), &info) != -1) {
|
||||
if (S_ISCHR(info.st_mode))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* if recheck == true, only not already opened devices are opened, if not, close then (re)open all */
|
||||
void CRCInput::open(bool recheck)
|
||||
{
|
||||
@@ -206,10 +246,22 @@ void CRCInput::open(bool recheck)
|
||||
|
||||
while ((dentry = readdir(dir)) != NULL)
|
||||
{
|
||||
if (dentry->d_type != DT_CHR) {
|
||||
if ((dentry->d_type != DT_CHR)
|
||||
#ifdef BOXMODEL_CS_HD2
|
||||
&& (dentry->d_type != DT_LNK)
|
||||
#endif
|
||||
|
||||
) {
|
||||
d_printf("[rcinput:%s] skipping '%s'\n", __func__, dentry->d_name);
|
||||
continue;
|
||||
}
|
||||
#ifdef BOXMODEL_CS_HD2
|
||||
if ((dentry->d_type == DT_LNK) && (!checkLnkDev("/dev/input/" + std::string(dentry->d_name)))) {
|
||||
d_printf("[rcinput:%s] skipping '%s'\n", __func__, dentry->d_name);
|
||||
continue;
|
||||
}
|
||||
id.type = dentry->d_type;
|
||||
#endif
|
||||
d_printf("[rcinput:%s] considering '%s'\n", __func__, dentry->d_name);
|
||||
id.path = "/dev/input/" + std::string(dentry->d_name);
|
||||
if (checkpath(id))
|
||||
|
Reference in New Issue
Block a user