Skip to content

Commit

Permalink
EIT start delay
Browse files Browse the repository at this point in the history
Compute the second component of the EIT start delay with the highest
input number instead of with the number of inputs.
The input number can be higher than the number of inputs because inputs (capture cards)
can be deleted and because new inputs always get a higher number.
This then can lead to a EIT start delay that is larger than intended.
  • Loading branch information
kmdewaal committed May 12, 2022
1 parent 77210f2 commit ef1323c
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions mythtv/libs/libmythtv/tv_rec.cpp
Expand Up @@ -1253,20 +1253,20 @@ static bool is_dishnet_eit(uint inputid)
return false;
}

// Number of capturecard instances including multirec instances
static int num_inputs(void)
// Highest capturecard instance number including multirec instances
static int get_highest_input(void)
{
MSqlQuery query(MSqlQuery::InitCon());

QString str =
"SELECT COUNT(cardid) "
"SELECT MAX(cardid) "
"FROM capturecard ";

query.prepare(str);

if (!query.exec() || !query.isActive())
{
MythDB::DBError("num_inputs", query);
MythDB::DBError("highest_input", query);
return -1;
}
if (query.next())
Expand All @@ -1279,11 +1279,11 @@ static std::chrono::seconds eit_start_rand(uint inputId, std::chrono::seconds ei
// Randomize start time a bit
auto timeout = std::chrono::seconds(MythRandom(0, eitTransportTimeout.count() / 3));

// Get the number of inputs and the position of the current input
// Use the highest input number and the current input number
// to distribute the scan start evenly over eitTransportTimeout
int no_inputs = num_inputs();
if (no_inputs > 0)
timeout += eitTransportTimeout * inputId / no_inputs;
int highest_input = get_highest_input();
if (highest_input > 0)
timeout += eitTransportTimeout * inputId / highest_input;

return timeout;
}
Expand Down

0 comments on commit ef1323c

Please sign in to comment.