diff options
author | mplayer-svn <svn@mplayerhq.hu> | 2012-06-09 11:11:57 +0000 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2012-08-03 03:44:44 +0200 |
commit | 1432aa41317518def4c70f79e044c379e5b87305 (patch) | |
tree | 3e2ed9b5c7efdc75001acc41ebb1eb799e06524a /stream | |
parent | 0b8540657ac1bc1a1db7a32206d7aa626441d2d4 (diff) | |
download | mpv-1432aa41317518def4c70f79e044c379e5b87305.tar.bz2 mpv-1432aa41317518def4c70f79e044c379e5b87305.tar.xz |
tv: reduce code duplication
Reduce some code duplication.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@34995 b3059339-0415-0410-9bf9-f77b7e298cf2
Author: reimar
Diffstat (limited to 'stream')
-rw-r--r-- | stream/tv.c | 35 |
1 files changed, 14 insertions, 21 deletions
diff --git a/stream/tv.c b/stream/tv.c index 9ca0c72dcc..10ae7132f5 100644 --- a/stream/tv.c +++ b/stream/tv.c @@ -395,6 +395,15 @@ static int tv_set_norm_i(tvi_handle_t *tvh, int norm) return 1; } +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); + tv_set_norm_i(tvh, chan->norm); + tv_set_freq(tvh, (unsigned long)(freq*16)); +} + static int open_tv(tvi_handle_t *tvh) { int i; @@ -568,10 +577,7 @@ static int open_tv(tvi_handle_t *tvh) tv_channel_current = tv_channel_current->next; } - mp_tmsg(MSGT_TV, MSGL_INFO, "Selected channel: %s - %s (freq: %.3f)\n", tv_channel_current->number, - tv_channel_current->name, (float)tv_channel_current->freq/1000); - tv_set_norm_i(tvh, tv_channel_current->norm); - tv_set_freq(tvh, (unsigned long)(((float)tv_channel_current->freq/1000)*16)); + set_norm_and_freq(tvh, tv_channel_current); tv_channel_last = tv_channel_current; } else { /* we need to set frequency */ @@ -988,11 +994,7 @@ int tv_step_channel(tvi_handle_t *tvh, int direction) { tv_channel_current = tv_channel_current->next; else tv_channel_current = tv_channel_list; - - tv_set_norm_i(tvh, tv_channel_current->norm); - tv_set_freq(tvh, (unsigned long)(((float)tv_channel_current->freq/1000)*16)); - mp_tmsg(MSGT_TV, MSGL_INFO, "Selected channel: %s - %s (freq: %.3f)\n", - tv_channel_current->number, tv_channel_current->name, (float)tv_channel_current->freq/1000); + set_norm_and_freq(tvh, tv_channel_current); } if (direction == TV_CHANNEL_LOWER) { tv_channel_last = tv_channel_current; @@ -1001,10 +1003,7 @@ int tv_step_channel(tvi_handle_t *tvh, int direction) { else while (tv_channel_current->next) tv_channel_current = tv_channel_current->next; - tv_set_norm_i(tvh, tv_channel_current->norm); - tv_set_freq(tvh, (unsigned long)(((float)tv_channel_current->freq/1000)*16)); - mp_tmsg(MSGT_TV, MSGL_INFO, "Selected channel: %s - %s (freq: %.3f)\n", - tv_channel_current->number, tv_channel_current->name, (float)tv_channel_current->freq/1000); + set_norm_and_freq(tvh, tv_channel_current); } } else tv_step_channel_real(tvh, direction); return 1; @@ -1044,10 +1043,7 @@ int tv_set_channel(tvi_handle_t *tvh, char *channel) { for (i = 1; i < channel_int; i++) if (tv_channel_current->next) tv_channel_current = tv_channel_current->next; - mp_tmsg(MSGT_TV, MSGL_INFO, "Selected channel: %s - %s (freq: %.3f)\n", tv_channel_current->number, - tv_channel_current->name, (float)tv_channel_current->freq/1000); - tv_set_norm_i(tvh, tv_channel_current->norm); - tv_set_freq(tvh, (unsigned long)(((float)tv_channel_current->freq/1000)*16)); + set_norm_and_freq(tvh, tv_channel_current); } else tv_set_channel_real(tvh, channel); return 1; } @@ -1062,10 +1058,7 @@ int tv_last_channel(tvi_handle_t *tvh) { tv_channel_last = tv_channel_current; tv_channel_current = tmp; - mp_tmsg(MSGT_TV, MSGL_INFO, "Selected channel: %s - %s (freq: %.3f)\n", tv_channel_current->number, - tv_channel_current->name, (float)tv_channel_current->freq/1000); - tv_set_norm_i(tvh, tv_channel_current->norm); - tv_set_freq(tvh, (unsigned long)(((float)tv_channel_current->freq/1000)*16)); + set_norm_and_freq(tvh, tv_channel_current); } else { int i; struct CHANLIST cl; |