Skip to content

Commit

Permalink
linuxdvb: rotor - try to fix the grace calculation routine for USALS …
Browse files Browse the repository at this point in the history
…and negative longtitudes
  • Loading branch information
perexg committed Sep 18, 2014
1 parent 34cb850 commit 03af723
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
20 changes: 16 additions & 4 deletions src/input/mpegts/linuxdvb/linuxdvb_rotor.c
Expand Up @@ -134,16 +134,28 @@ linuxdvb_rotor_grace
( linuxdvb_diseqc_t *ld, dvb_mux_t *lm )
{
linuxdvb_rotor_t *lr = (linuxdvb_rotor_t*)ld;
linuxdvb_satconf_t *ls = ld->ld_satconf->lse_parent;
int newpos, curpos, delta;

if (!ld->ld_satconf->lse_parent->ls_orbital_dir || lr->lr_rate == 0)
if (!ls->ls_orbital_dir || lr->lr_rate == 0)
return 120;

int curpos = ld->ld_satconf->lse_parent->ls_orbital_pos;
if (idnode_is_instance(&lr->ld_id, &linuxdvb_rotor_gotox_class))
newpos = lr->lr_position; /* GotoX */
else
newpos = (lr->lr_sat_lon + 0.005) * 100; /* USALS */

if (ld->ld_satconf->lse_parent->ls_orbital_dir == 'W')
curpos = ls->ls_orbital_pos;
if (ls->ls_orbital_dir == 'W')
curpos = -(curpos);
delta = abs(deltaI32(curpos, newpos));

/* ignore very small movements like 0.8W and 1W */
if (delta <= 2)
return 0;

return (lr->lr_rate*(deltaU32(curpos, lr->lr_position))+999)/1000;
/* add one extra second, because of the rounding issue */
return ((lr->lr_rate*delta+999)/1000) + 1;
}

static int
Expand Down
1 change: 1 addition & 0 deletions src/tvheadend.h
Expand Up @@ -708,6 +708,7 @@ int rmtree ( const char *path );

char *regexp_escape ( const char *str );

static inline int32_t deltaI32(int32_t a, int32_t b) { return (a > b) ? (a - b) : (b - a); }
static inline uint32_t deltaU32(uint32_t a, uint32_t b) { return (a > b) ? (a - b) : (b - a); }

#define SKEL_DECLARE(name, type) type *name;
Expand Down

0 comments on commit 03af723

Please sign in to comment.