Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 12 Nov 2016 17:27:28 +0000 (UTC)
From:      Hans Petter Selasky <hselasky@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org
Subject:   svn commit: r308571 - stable/11/sys/dev/sound/usb
Message-ID:  <201611121727.uACHRSTr028133@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: hselasky
Date: Sat Nov 12 17:27:28 2016
New Revision: 308571
URL: https://svnweb.freebsd.org/changeset/base/308571

Log:
  MFC r308437 and r308461:
  Range check the jitter values to avoid bogus sample rate adjustments.
  The expected deviation should not be more than 1Hz per second. The USB
  v2.0 specification also mandates this requirement. Refer to chapter
  5.12.4.2 about feedback.
  
  Allow higher sample rates to have more jitter than lower ones.
  
  PR:		208791

Modified:
  stable/11/sys/dev/sound/usb/uaudio.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/dev/sound/usb/uaudio.c
==============================================================================
--- stable/11/sys/dev/sound/usb/uaudio.c	Sat Nov 12 17:24:41 2016	(r308570)
+++ stable/11/sys/dev/sound/usb/uaudio.c	Sat Nov 12 17:27:28 2016	(r308571)
@@ -2078,9 +2078,23 @@ uaudio_chan_play_sync_callback(struct us
 		 * Use feedback value as fallback when there is no
 		 * recording channel:
 		 */
-		if (ch->priv_sc->sc_rec_chan.num_alt == 0)
-			ch->jitter_curr = temp - sample_rate;
+		if (ch->priv_sc->sc_rec_chan.num_alt == 0) {
+			int32_t jitter_max = howmany(sample_rate, 16000);
 
+			/*
+			 * Range check the jitter values to avoid
+			 * bogus sample rate adjustments. The expected
+			 * deviation should not be more than 1Hz per
+			 * second. The USB v2.0 specification also
+			 * mandates this requirement. Refer to chapter
+			 * 5.12.4.2 about feedback.
+			 */
+			ch->jitter_curr = temp - sample_rate;
+			if (ch->jitter_curr > jitter_max)
+				ch->jitter_curr = jitter_max;
+			else if (ch->jitter_curr < -jitter_max)
+				ch->jitter_curr = -jitter_max;
+		}
 		ch->feedback_rate = temp;
 		break;
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201611121727.uACHRSTr028133>