diff options
Diffstat (limited to 'stream/tv.c')
-rw-r--r-- | stream/tv.c | 57 |
1 files changed, 31 insertions, 26 deletions
diff --git a/stream/tv.c b/stream/tv.c index 922fa5f008..e8346e1b15 100644 --- a/stream/tv.c +++ b/stream/tv.c @@ -111,6 +111,11 @@ void tv_start_scan(tvi_handle_t *tvh, int start) tvh->tv_param->scan=start?1:0; } +static int tv_set_freq_float(tvi_handle_t *tvh, float freq) +{ + return tv_set_freq(tvh, freq/1000.0*16); +} + static void tv_scan(tvi_handle_t *tvh) { unsigned int now; @@ -134,7 +139,7 @@ static void tv_scan(tvi_handle_t *tvh) scan=calloc(1,sizeof(tv_scan_t)); tvh->scan=scan; cl = tvh->chanlist_s[scan->channel_num]; - tv_set_freq(tvh, (unsigned long)(((float)cl.freq/1000)*16)); + tv_set_freq_float(tvh, cl.freq); scan->scan_timer=now+1e6*tvh->tv_param->scan_period; } if(scan->scan_timer>now) @@ -191,12 +196,12 @@ static void tv_scan(tvi_handle_t *tvh) } if (!tv_channel_current) tv_channel_current=tv_channel_list; if (tv_channel_current) - tv_set_freq(tvh, (unsigned long)(((float)tv_channel_current->freq/1000)*16)); + tv_set_freq_float(tvh, tv_channel_current->freq); free(tvh->scan); tvh->scan=NULL; }else{ cl = tvh->chanlist_s[scan->channel_num]; - tv_set_freq(tvh, (unsigned long)(((float)cl.freq/1000)*16)); + tv_set_freq_float(tvh, cl.freq); mp_msg(MSGT_TV, MSGL_INFO, "Trying: %s (%.2f). \n",cl.name,1e-3*cl.freq); } } @@ -393,18 +398,17 @@ static int tv_set_norm_i(tvi_handle_t *tvh, int norm) static void set_norm_and_freq(tvi_handle_t *tvh, tv_channels_t *chan) { - float freq = (float)chan->freq/1000; mp_msg(MSGT_TV, MSGL_INFO, "Selected channel: %s - %s (freq: %.3f)\n", - chan->number, chan->name, freq); + chan->number, chan->name, chan->freq/1000.0); tv_set_norm_i(tvh, chan->norm); - tv_set_freq(tvh, (unsigned long)(freq*16)); + tv_set_freq_float(tvh, chan->freq); } static int open_tv(tvi_handle_t *tvh) { int i; const tvi_functions_t *funcs = tvh->functions; - int tv_fmt_list[] = { + static const int tv_fmt_list[] = { IMGFMT_YV12, IMGFMT_I420, IMGFMT_UYVY, @@ -519,10 +523,11 @@ static int open_tv(tvi_handle_t *tvh) } } - if (tvh->chanlist == -1) + if (tvh->chanlist == -1) { mp_tmsg(MSGT_TV, MSGL_WARN, "Unable to find selected channel list! (%s)\n", tvh->tv_param->chanlist); - else + return 0; + } else mp_tmsg(MSGT_TV, MSGL_V, "Selected channel list: %s (including %d channels)\n", chanlists[tvh->chanlist].name, chanlists[tvh->chanlist].count); @@ -583,7 +588,7 @@ static int open_tv(tvi_handle_t *tvh) funcs->control(tvh->priv, TVI_CONTROL_TUN_GET_FREQ, &freq); mp_tmsg(MSGT_TV, MSGL_V, "Selected frequency: %lu (%.3f)\n", - freq, (float)freq/16); + freq, freq/16.0); } if (tvh->tv_param->channel) { @@ -600,8 +605,8 @@ static int open_tv(tvi_handle_t *tvh) strcpy(tv_channel_last_real, cl.name); tvh->channel = i; mp_tmsg(MSGT_TV, MSGL_INFO, "Selected channel: %s (freq: %.3f)\n", - cl.name, (float)cl.freq/1000); - tv_set_freq(tvh, (unsigned long)(((float)cl.freq/1000)*16)); + cl.name, cl.freq/1000.0); + tv_set_freq_float(tvh, cl.freq); break; } } @@ -900,7 +905,7 @@ int tv_get_freq(tvi_handle_t *tvh, unsigned long *freq) { tvh->functions->control(tvh->priv, TVI_CONTROL_TUN_GET_FREQ, freq); mp_tmsg(MSGT_TV, MSGL_V, "Current frequency: %lu (%.3f)\n", - *freq, (float)*freq/16); + *freq, *freq/16.0); } return 1; } @@ -916,7 +921,7 @@ int tv_set_freq(tvi_handle_t *tvh, unsigned long freq) tvh->functions->control(tvh->priv, TVI_CONTROL_TUN_GET_FREQ, &freq); mp_tmsg(MSGT_TV, MSGL_V, "Current frequency: %lu (%.3f)\n", - freq, (float)freq/16); + freq, freq/16.0); } return 1; } @@ -958,9 +963,9 @@ int tv_step_channel_real(tvi_handle_t *tvh, int direction) { strcpy(tv_channel_last_real, tvh->chanlist_s[tvh->channel].name); cl = tvh->chanlist_s[--tvh->channel]; - mp_tmsg(MSGT_TV, MSGL_INFO, "Selected channel: %s (freq: %.3f)\n", - cl.name, (float)cl.freq/1000); - tv_set_freq(tvh, (unsigned long)(((float)cl.freq/1000)*16)); + mp_msg(MSGT_TV, MSGL_INFO, "Selected channel: %s (freq: %.3f)\n", + cl.name, cl.freq/1000.0); + tv_set_freq_float(tvh, cl.freq); } } @@ -970,9 +975,9 @@ int tv_step_channel_real(tvi_handle_t *tvh, int direction) { strcpy(tv_channel_last_real, tvh->chanlist_s[tvh->channel].name); cl = tvh->chanlist_s[++tvh->channel]; - mp_tmsg(MSGT_TV, MSGL_INFO, "Selected channel: %s (freq: %.3f)\n", - cl.name, (float)cl.freq/1000); - tv_set_freq(tvh, (unsigned long)(((float)cl.freq/1000)*16)); + mp_msg(MSGT_TV, MSGL_INFO, "Selected channel: %s (freq: %.3f)\n", + cl.name, cl.freq/1000.0); + tv_set_freq_float(tvh, cl.freq); } } return 1; @@ -1016,9 +1021,9 @@ int tv_set_channel_real(tvi_handle_t *tvh, char *channel) { if (!strcasecmp(cl.name, channel)) { tvh->channel = i; - mp_tmsg(MSGT_TV, MSGL_INFO, "Selected channel: %s (freq: %.3f)\n", - cl.name, (float)cl.freq/1000); - tv_set_freq(tvh, (unsigned long)(((float)cl.freq/1000)*16)); + mp_msg(MSGT_TV, MSGL_INFO, "Selected channel: %s (freq: %.3f)\n", + cl.name, cl.freq/1000.0); + tv_set_freq_float(tvh, cl.freq); break; } } @@ -1063,9 +1068,9 @@ int tv_last_channel(tvi_handle_t *tvh) { { strcpy(tv_channel_last_real, tvh->chanlist_s[tvh->channel].name); tvh->channel = i; - mp_tmsg(MSGT_TV, MSGL_INFO, "Selected channel: %s (freq: %.3f)\n", - cl.name, (float)cl.freq/1000); - tv_set_freq(tvh, (unsigned long)(((float)cl.freq/1000)*16)); + mp_msg(MSGT_TV, MSGL_INFO, "Selected channel: %s (freq: %.3f)\n", + cl.name, cl.freq/1000.0); + tv_set_freq_float(tvh, cl.freq); break; } } |