svn commit: r308573 - stable/9/sys/dev/sound/usb

Hans Petter Selasky hselasky at FreeBSD.org
Sat Nov 12 17:32:24 UTC 2016


Author: hselasky
Date: Sat Nov 12 17:32:22 2016
New Revision: 308573
URL: https://svnweb.freebsd.org/changeset/base/308573

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/9/sys/dev/sound/usb/uaudio.c
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/dev/sound/usb/uaudio.c
==============================================================================
--- stable/9/sys/dev/sound/usb/uaudio.c	Sat Nov 12 17:30:55 2016	(r308572)
+++ stable/9/sys/dev/sound/usb/uaudio.c	Sat Nov 12 17:32:22 2016	(r308573)
@@ -2047,9 +2047,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;
 


More information about the svn-src-all mailing list