mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-26 23:13:13 +02:00
zapit: add delay when retrying SCR tuning
this is not exactly the algorithm as described in EN50494 sect.8, but rand() is probably good enough :-)
This commit is contained in:
@@ -156,8 +156,11 @@ bool CServiceScan::tuneFrequency(FrontendParameters *feparams, uint8_t polarizat
|
||||
if (abort_scan)
|
||||
break;
|
||||
retry--;
|
||||
if (retry)
|
||||
printf("[unicable] [scan] retrying tune, retry=%d\n", retry);
|
||||
if (retry) {
|
||||
int rand_us = (rand() * 1000000LL / RAND_MAX);
|
||||
printf("[scan] SCR retrying tune, retry=%d after %dms\n", retry, rand_us/1000);
|
||||
usleep(rand_us);
|
||||
}
|
||||
} while (retry > 0);
|
||||
return false;
|
||||
}
|
||||
|
@@ -511,8 +511,9 @@ bool CZapit::ZapIt(const t_channel_id channel_id, bool forupdate, bool startplay
|
||||
|
||||
live_channel_id = current_channel->getChannelID();
|
||||
SaveSettings(false);
|
||||
srand(time(NULL));
|
||||
|
||||
/* retry tuning twice when using unicable */
|
||||
/* retry tuning twice when using unicable, TODO: EN50494 sect.8 specifies 4 retries... */
|
||||
int retry = (live_fe->getDiseqcType() == DISEQC_UNICABLE) * 2;
|
||||
again:
|
||||
if(!TuneChannel(live_fe, newchannel, transponder_change)) {
|
||||
@@ -521,7 +522,11 @@ bool CZapit::ZapIt(const t_channel_id channel_id, bool forupdate, bool startplay
|
||||
SendEvent(CZapitClient::EVT_TUNE_COMPLETE, &chid, sizeof(t_channel_id));
|
||||
return false;
|
||||
}
|
||||
printf("[zapit] %s:1 unicable retry tuning %d\n", __func__, retry);
|
||||
int rand_us = (rand() * 1000000LL / RAND_MAX); /* max. 1 second delay */
|
||||
printf("[zapit] %s:1 SCR retry tuning %d after %dms\n", __func__, retry, rand_us / 1000);
|
||||
/* EN50494 sect.8 specifies an elaborated way of calculating the delay, but I'm
|
||||
* pretty sure rand() is not much worse :-) */
|
||||
usleep(rand_us);
|
||||
live_fe->tuned = false;
|
||||
retry--;
|
||||
goto again;
|
||||
@@ -536,7 +541,9 @@ bool CZapit::ZapIt(const t_channel_id channel_id, bool forupdate, bool startplay
|
||||
failed = !ParsePatPmt(current_channel);
|
||||
|
||||
if (failed && retry > 0) {
|
||||
printf("[zapit] %s:2 unicable retry tuning %d\n", __func__, retry);
|
||||
int rand_us = (rand() * 1000000LL / RAND_MAX);
|
||||
printf("[zapit] %s:2 SCR retry tuning %d after %dms\n", __func__, retry, rand_us / 1000);
|
||||
usleep(rand_us);
|
||||
live_fe->tuned = false;
|
||||
retry--;
|
||||
goto again;
|
||||
|
Reference in New Issue
Block a user