From owner-svn-src-stable-11@freebsd.org Sat Nov 12 17:27:29 2016 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id AF956C3D6D4; Sat, 12 Nov 2016 17:27:29 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 7E55E1D08; Sat, 12 Nov 2016 17:27:29 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uACHRSPY028134; Sat, 12 Nov 2016 17:27:28 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uACHRSTr028133; Sat, 12 Nov 2016 17:27:28 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <201611121727.uACHRSTr028133@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Sat, 12 Nov 2016 17:27:28 +0000 (UTC) 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 X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 12 Nov 2016 17:27:29 -0000 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;