| | 117 | uint SourceUtil::GetConnectionCount(uint sourceid) |
| | 118 | { |
| | 119 | QStringList types = get_cardtypes(sourceid); |
| | 120 | return types.size(); |
| | 121 | } |
| | 122 | |
| | 123 | bool SourceUtil::IsProperlyConnected(uint sourceid, bool strict) |
| | 124 | { |
| | 125 | QStringList types = get_cardtypes(sourceid); |
| | 126 | QMap<QString,uint> counts; |
| | 127 | QStringList::const_iterator it = types.begin(); |
| | 128 | for (; it != types.end(); ++it) |
| | 129 | { |
| | 130 | counts[*it]++; |
| | 131 | |
| | 132 | counts[CardUtil::IsEncoder(*it) ? "ENCODER" : "NOT_ENCODER"]++; |
| | 133 | counts[CardUtil::IsUnscanable(*it) ? "NO_SCAN" : "SCAN"]++; |
| | 134 | |
| | 135 | if (CardUtil::IsTuningAnalog(*it)) |
| | 136 | counts["ANALOG_TUNING"]++; |
| | 137 | else if (CardUtil::IsTuningDigital(*it)) |
| | 138 | counts["DIGITAL_TUNING"]++; |
| | 139 | else |
| | 140 | counts["OTHER_TUNING"]++; |
| | 141 | } |
| | 142 | |
| | 143 | bool tune_mismatch = counts["ANALOG_TUNING"] && counts["DIGITAL_TUNING"]; |
| | 144 | bool enc_mismatch = counts["ENCODER"] && counts["NOT_ENCODER"]; |
| | 145 | bool scan_mismatch = counts["SCAN"] && counts["NO_SCAN"]; |
| | 146 | bool fw_mismatch = (counts["FIREWIRE"] && |
| | 147 | (counts["FIREWIRE"] < types.size())); |
| | 148 | |
| | 149 | if (tune_mismatch) |
| | 150 | { |
| | 151 | uint a = counts["ANALOG_TUNERS"]; |
| | 152 | uint d = counts["DIGITAL_TUNERS"]; |
| | 153 | VERBOSE(VB_GENERAL, QString("SourceUtil::IsProperlyConnected(): ") + |
| | 154 | QString("Source ID %1 ").arg(sourceid) + |
| | 155 | QString("appears to be connected\n\t\t\tto %1 analog tuner%2,") |
| | 156 | .arg(a).arg((1 == a) ? "":"s") + |
| | 157 | QString("and %1 digital tuner%2.\n\t\t\t") |
| | 158 | .arg(d).arg((1 == d) ? "":"s") + |
| | 159 | QString("Can't mix analog and digital tuning information.")); |
| | 160 | } |
| | 161 | |
| | 162 | if (enc_mismatch) |
| | 163 | { |
| | 164 | uint a = counts["ENCODER"]; |
| | 165 | uint d = counts["NOT_ENCODER"]; |
| | 166 | VERBOSE(VB_GENERAL, QString("SourceUtil::IsProperlyConnected(): ") + |
| | 167 | QString("Source ID %1 ").arg(sourceid) + |
| | 168 | QString("appears to be connected\n\t\t\tto %1 encoder%2, ") |
| | 169 | .arg(a).arg((1 == a) ? "":"s") + |
| | 170 | QString("and %1 non-encoder%2. ") |
| | 171 | .arg(d).arg((1 == d) ? "":"s") + |
| | 172 | QString("This is probably a bad idea.")); |
| | 173 | } |
| | 174 | |
| | 175 | if (scan_mismatch) |
| | 176 | { |
| | 177 | uint a = counts["SCAN"]; |
| | 178 | uint d = counts["NO_SCAN"]; |
| | 179 | VERBOSE(VB_GENERAL, QString("SourceUtil::IsProperlyConnected(): ") + |
| | 180 | QString("Source ID %1 ").arg(sourceid) + |
| | 181 | QString("appears to be connected\n\t\t\t" |
| | 182 | "to %1 scanable input%2, ") |
| | 183 | .arg(a).arg((1 == a) ? "":"s") + |
| | 184 | QString("and %1 non-scanable input%2. ") |
| | 185 | .arg(d).arg((1 == d) ? "":"s") + |
| | 186 | QString("This may be a problem.")); |
| | 187 | } |
| | 188 | |
| | 189 | if (fw_mismatch) |
| | 190 | { |
| | 191 | VERBOSE(VB_GENERAL, QString("SourceUtil::IsProperlyConnected(): ") + |
| | 192 | QString( |
| | 193 | "Source ID %1 appears to be connected\n\t\t\t" |
| | 194 | "to both firewire and non-firewire inputs. " |
| | 195 | "This is probably a bad idea.").arg(sourceid)); |
| | 196 | } |
| | 197 | |
| | 198 | if (!strict) |
| | 199 | return !tune_mismatch; |
| | 200 | |
| | 201 | return !tune_mismatch && !enc_mismatch && !scan_mismatch && !fw_mismatch; |
| | 202 | } |
| | 203 | |