diff mbox

[tvtime,06/17] mute: Delay unmute on signal lock to give msp3400 time to sync

Message ID 1455389258-13470-6-git-send-email-hdegoede@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Hans de Goede Feb. 13, 2016, 6:47 p.m. UTC
Delay unmute on signal lock, this fixes a loud plop sound on changing
channels on cards with a msp3400 stereo sound decoder.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 src/videoinput.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
diff mbox

Patch

diff --git a/src/videoinput.c b/src/videoinput.c
index 0af6ab7..f66a35e 100644
--- a/src/videoinput.c
+++ b/src/videoinput.c
@@ -123,6 +123,12 @@  int videoinput_get_time_per_field( int norm )
     }
 }
 
+static int videoinput_get_unmute_delay( int norm )
+{
+    /* The msp3400 needs some time before it provides stable audio */
+    return 400000 / videoinput_get_time_per_field( norm );
+}
+
 typedef struct capture_buffer_s
 {
     struct v4l2_buffer vidbuf;
@@ -158,6 +164,7 @@  struct videoinput_s
     int hasaudio;
     int audiomode;
     int change_muted;
+    int change_muted_delay;
     int user_muted;
     int hw_muted;
 
@@ -360,6 +367,7 @@  videoinput_t *videoinput_new( config_t *cfg, int norm, int verbose,
     vidin->signal_recover_wait = 0;
     vidin->signal_acquire_wait = 0;
     vidin->change_muted = 1;
+    vidin->change_muted_delay = videoinput_get_unmute_delay( norm );
     vidin->user_muted = user_muted;
     vidin->hw_muted = 1;
     vidin->hasaudio = 1;
@@ -752,6 +760,7 @@  void videoinput_set_tuner_freq( videoinput_t *vidin, int freqKHz )
         }
 
         vidin->change_muted = 1;
+        vidin->change_muted_delay = videoinput_get_unmute_delay( vidin->norm );
         videoinput_do_mute( vidin );
         vidin->cur_tuner_state = TUNER_STATE_SIGNAL_DETECTED;
         vidin->signal_acquire_wait = SIGNAL_ACQUIRE_DELAY;
@@ -921,7 +930,7 @@  int videoinput_check_for_signal( videoinput_t *vidin, int check_freq_present )
                 vidin->cur_tuner_state = TUNER_STATE_HAS_SIGNAL;
             }
         default:
-            if( vidin->change_muted ) {
+            if( vidin->change_muted && --vidin->change_muted_delay == 0 ) {
                 vidin->change_muted = 0;
                 videoinput_do_mute( vidin );
             }
@@ -934,6 +943,7 @@  int videoinput_check_for_signal( videoinput_t *vidin, int check_freq_present )
             vidin->cur_tuner_state = TUNER_STATE_SIGNAL_LOST;
             vidin->signal_recover_wait = SIGNAL_RECOVER_DELAY;
             vidin->change_muted = 1;
+            vidin->change_muted_delay = videoinput_get_unmute_delay( vidin->norm );
             videoinput_do_mute( vidin );
         case TUNER_STATE_SIGNAL_LOST:
             if( vidin->signal_recover_wait ) {