mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-27 07:23:09 +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)
|
if (abort_scan)
|
||||||
break;
|
break;
|
||||||
retry--;
|
retry--;
|
||||||
if (retry)
|
if (retry) {
|
||||||
printf("[unicable] [scan] retrying tune, retry=%d\n", 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);
|
} while (retry > 0);
|
||||||
return false;
|
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();
|
live_channel_id = current_channel->getChannelID();
|
||||||
SaveSettings(false);
|
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;
|
int retry = (live_fe->getDiseqcType() == DISEQC_UNICABLE) * 2;
|
||||||
again:
|
again:
|
||||||
if(!TuneChannel(live_fe, newchannel, transponder_change)) {
|
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));
|
SendEvent(CZapitClient::EVT_TUNE_COMPLETE, &chid, sizeof(t_channel_id));
|
||||||
return false;
|
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;
|
live_fe->tuned = false;
|
||||||
retry--;
|
retry--;
|
||||||
goto again;
|
goto again;
|
||||||
@@ -536,7 +541,9 @@ bool CZapit::ZapIt(const t_channel_id channel_id, bool forupdate, bool startplay
|
|||||||
failed = !ParsePatPmt(current_channel);
|
failed = !ParsePatPmt(current_channel);
|
||||||
|
|
||||||
if (failed && retry > 0) {
|
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;
|
live_fe->tuned = false;
|
||||||
retry--;
|
retry--;
|
||||||
goto again;
|
goto again;
|
||||||
|
Reference in New Issue
Block a user