/** \fn DVBChannel::GetChanID() const * \brief Returns Channel ID * \bug This only works if there is only one input on the card. */ int DVBChannel::GetChanID() const { int cardid = GetCardID(); MSqlQuery query(MSqlQuery::InitCon()); query.prepare("SELECT chanid " "FROM channel, cardinput " "WHERE cardinput.sourceid = channel.sourceid AND " " channel.channum = :CHANNUM AND " " cardinput.cardid = :CARDID"); query.bindValue(":CHANNUM", m_curchannelname); query.bindValue(":CARDID", cardid); if (!query.exec() || !query.isActive()) { MythDB::DBError("fetching chanid", query); return -1; } if (query.size() <= 0) return -1; query.next(); return query.value(0).toInt(); }
QString DTVChannel::GetSuggestedTuningMode(bool is_live_tv) const { uint cardid = GetCardID(); QString input = GetCurrentInput(); uint quickTuning = 0; if (cardid && !input.isEmpty()) quickTuning = CardUtil::GetQuickTuning(cardid, input); bool useQuickTuning = (quickTuning && is_live_tv) || (quickTuning > 1); QMutexLocker locker(&dtvinfo_lock); if (!useQuickTuning && ((sistandard == "atsc") || (sistandard == "dvb"))) { QString tmp = sistandard; tmp.detach(); return tmp; } return "mpeg"; }
bool DVBChannel::Open(DVBChannel *who) { LOG(VB_CHANNEL, LOG_INFO, LOC + "Opening DVB channel"); QMutexLocker locker(&hw_lock); if (fd_frontend >= 0) { is_open[who] = true; return true; } DVBChannel *master = GetMasterLock(); if (master != this) { if (!master->Open(who)) { ReturnMasterLock(master); return false; } fd_frontend = master->fd_frontend; frontend_name = master->frontend_name; tunerType = master->tunerType; capabilities = master->capabilities; ext_modulations = master->ext_modulations; frequency_minimum = master->frequency_minimum; frequency_maximum = master->frequency_maximum; symbol_rate_minimum = master->symbol_rate_minimum; symbol_rate_maximum = master->symbol_rate_maximum; is_open[who] = true; if (!InitializeInputs()) { Close(); ReturnMasterLock(master); return false; } ReturnMasterLock(master); return true; } ReturnMasterLock(master); // if we're the master we don't need this lock.. QString devname = CardUtil::GetDeviceName(DVB_DEV_FRONTEND, device); QByteArray devn = devname.toAscii(); for (int tries = 1; ; ++tries) { fd_frontend = open(devn.constData(), O_RDWR | O_NONBLOCK); if (fd_frontend >= 0) break; LOG(VB_GENERAL, LOG_WARNING, LOC + "Opening DVB frontend device failed." + ENO); if (tries >= 20 || (errno != EBUSY && errno != EAGAIN)) { LOG(VB_GENERAL, LOG_ERR, LOC + QString("Failed to open DVB frontend device due to " "fatal error or too many attempts.")); return false; } usleep(50000); } dvb_frontend_info info; memset(&info, 0, sizeof(info)); if (ioctl(fd_frontend, FE_GET_INFO, &info) < 0) { LOG(VB_GENERAL, LOG_ERR, LOC + "Failed to get frontend information." + ENO); close(fd_frontend); fd_frontend = -1; return false; } frontend_name = info.name; tunerType = info.type; #if HAVE_FE_CAN_2G_MODULATION if (tunerType == DTVTunerType::kTunerTypeDVBS1 && (info.caps & FE_CAN_2G_MODULATION)) tunerType = DTVTunerType::kTunerTypeDVBS2; #endif // HAVE_FE_CAN_2G_MODULATION capabilities = info.caps; frequency_minimum = info.frequency_min; frequency_maximum = info.frequency_max; symbol_rate_minimum = info.symbol_rate_min; symbol_rate_maximum = info.symbol_rate_max; LOG(VB_RECORD, LOG_INFO, LOC + QString("Using DVB card %1, with frontend '%2'.") .arg(device).arg(frontend_name)); // Turn on the power to the LNB if (tunerType.IsDiSEqCSupported()) { diseqc_tree = diseqc_dev.FindTree(GetCardID()); if (diseqc_tree) diseqc_tree->Open(fd_frontend); } dvbcam->Start(); first_tune = true; if (!InitializeInputs()) { Close(); return false; } if (fd_frontend >= 0) is_open[who] = true; return (fd_frontend >= 0); }