bool HDHRStreamHandler::UpdateFilters(void) { if (_tune_mode == hdhrTuneModeFrequency) _tune_mode = hdhrTuneModeFrequencyPid; if (_tune_mode != hdhrTuneModeFrequencyPid) { LOG(VB_GENERAL, LOG_ERR, LOC + "UpdateFilters called in wrong tune mode"); return false; } #ifdef DEBUG_PID_FILTERS LOG(VB_RECORD, LOG_INFO, LOC + "UpdateFilters()"); #endif // DEBUG_PID_FILTERS QMutexLocker locker(&_pid_lock); QString filter = ""; vector<uint> range_min; vector<uint> range_max; PIDInfoMap::const_iterator it = _pid_info.begin(); for (; it != _pid_info.end(); ++it) { range_min.push_back(it.key()); PIDInfoMap::const_iterator eit = it; for (++eit; (eit != _pid_info.end()) && (it.key() + 1 == eit.key()); ++it, ++eit); range_max.push_back(it.key()); } if (range_min.size() > 16) { range_min.resize(16); uint pid_max = range_max.back(); range_max.resize(15); range_max.push_back(pid_max); } for (uint i = 0; i < range_min.size(); i++) { filter += filt_str(range_min[i]); if (range_min[i] != range_max[i]) filter += QString("-%1").arg(filt_str(range_max[i])); filter += " "; } filter = filter.trimmed(); QString new_filter = TunerSet("filter", filter); #ifdef DEBUG_PID_FILTERS QString msg = QString("Filter: '%1'").arg(filter); if (filter != new_filter) msg += QString("\n\t\t\t\t'%2'").arg(new_filter); LOG(VB_RECORD, LOG_INFO, LOC + msg); #endif // DEBUG_PID_FILTERS return filter == new_filter; }
bool HDHRStreamHandler::UpdateFilters(void) { if (_tune_mode == hdhrTuneModeFrequency) _tune_mode = hdhrTuneModeFrequencyPid; if (_tune_mode != hdhrTuneModeFrequencyPid) { VERBOSE(VB_IMPORTANT, LOC_ERR + "UpdateFilters called in wrong tune mode"); return false; } #ifdef DEBUG_PID_FILTERS VERBOSE(VB_RECORD, LOC + "UpdateFilters()"); #endif // DEBUG_PID_FILTERS QMutexLocker locker(&_pid_lock); QString filter = ""; vector<uint> range_min; vector<uint> range_max; for (uint i = 0; i < _pid_info.size(); i++) { uint pid_min = _pid_info[i]; uint pid_max = pid_min; for (uint j = i + 1; j < _pid_info.size(); j++) { if (pid_max + 1 != _pid_info[j]) break; pid_max++; i++; } range_min.push_back(pid_min); range_max.push_back(pid_max); } if (range_min.size() > 16) { range_min.resize(16); uint pid_max = range_max.back(); range_max.resize(15); range_max.push_back(pid_max); } for (uint i = 0; i < range_min.size(); i++) { filter += filt_str(range_min[i]); if (range_min[i] != range_max[i]) filter += QString("-%1").arg(filt_str(range_max[i])); filter += " "; } filter = filter.trimmed(); QString new_filter = TunerSet("filter", filter); #ifdef DEBUG_PID_FILTERS QString msg = QString("Filter: '%1'").arg(filter); if (filter != new_filter) msg += QString("\n\t\t\t\t'%2'").arg(new_filter); VERBOSE(VB_RECORD, LOC + msg); #endif // DEBUG_PID_FILTERS return filter == new_filter; }