From owner-svn-ports-all@freebsd.org Thu Jul 4 15:46:17 2019 Return-Path: Delivered-To: svn-ports-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6DC7615D8363; Thu, 4 Jul 2019 15:46:17 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 1360995FC9; Thu, 4 Jul 2019 15:46:17 +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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id BCBCA2501F; Thu, 4 Jul 2019 15:46:16 +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 x64FkGsY005662; Thu, 4 Jul 2019 15:46:16 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x64FkGZI005660; Thu, 4 Jul 2019 15:46:16 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <201907041546.x64FkGZI005660@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Thu, 4 Jul 2019 15:46:16 +0000 (UTC) To: ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org Subject: svn commit: r505839 - in head/audio/alsa-plugins: . files X-SVN-Group: ports-head X-SVN-Commit-Author: hselasky X-SVN-Commit-Paths: in head/audio/alsa-plugins: . files X-SVN-Commit-Revision: 505839 X-SVN-Commit-Repository: ports MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 1360995FC9 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.96 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.97)[-0.966,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-ports-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the ports tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 04 Jul 2019 15:46:17 -0000 Author: hselasky Date: Thu Jul 4 15:46:15 2019 New Revision: 505839 URL: https://svnweb.freebsd.org/changeset/ports/505839 Log: Fix issues with ALSA OSS backend for firefox and chrome. 1) When read() or write() fails due to EAGAIN because no buffer is available or buffer is full, return 0 instead of failure. Else clients may simply close the device and re-open it instantly chopping the audio. 2) Implement OSS delay function to fix an issue with negative delays. 3) Use at least 16ms of HW buffer by default to avoid jitter. Approved by: pi, jbeich Modified: head/audio/alsa-plugins/Makefile head/audio/alsa-plugins/files/patch-oss_pcm__oss.c Modified: head/audio/alsa-plugins/Makefile ============================================================================== --- head/audio/alsa-plugins/Makefile Thu Jul 4 15:38:20 2019 (r505838) +++ head/audio/alsa-plugins/Makefile Thu Jul 4 15:46:15 2019 (r505839) @@ -3,7 +3,7 @@ PORTNAME= alsa-plugins PORTVERSION= 1.1.1 -PORTREVISION= 4 +PORTREVISION= 5 CATEGORIES= audio MASTER_SITES= ftp://ftp.alsa-project.org/pub/plugins/ \ GENTOO @@ -15,8 +15,9 @@ LICENSE= LGPL21+ LIB_DEPENDS= libasound.so:audio/alsa-lib -GNU_CONFIGURE= yes USES= alias libtool:keepla localbase pkgconfig tar:bzip2 + +GNU_CONFIGURE= yes EXTRA_PATCHES+= ${FILESDIR}/alsa-plugins.patch INSTALL_TARGET= install-strip CPPFLAGS+= -I${.CURDIR}/../alsa-lib/files Modified: head/audio/alsa-plugins/files/patch-oss_pcm__oss.c ============================================================================== --- head/audio/alsa-plugins/files/patch-oss_pcm__oss.c Thu Jul 4 15:38:20 2019 (r505838) +++ head/audio/alsa-plugins/files/patch-oss_pcm__oss.c Thu Jul 4 15:46:15 2019 (r505839) @@ -1,4 +1,4 @@ ---- oss/pcm_oss.c.orig 2016-07-26 13:27:23 UTC +--- oss/pcm_oss.c.orig 2019-07-04 14:37:07 UTC +++ oss/pcm_oss.c @@ -22,7 +22,11 @@ #include @@ -12,8 +12,56 @@ #define ARRAY_SIZE(x) (sizeof(x) / sizeof(*(x))) -@@ -258,7 +262,7 @@ static int oss_drain(snd_pcm_ioplug_t *i +@@ -74,11 +78,19 @@ static snd_pcm_sframes_t oss_write(snd_p + size *= oss->frame_bytes; + result = write(oss->fd, buf, size); + #ifdef __FreeBSD__ +- if (result == -1) +- return -errno; ++ if (result == -1) { ++ if (errno == EAGAIN) ++ return 0; ++ else ++ return -errno; ++ } + #else +- if (result <= 0) +- return result; ++ if (result <= 0) { ++ if (result == -EAGAIN) ++ return 0; ++ else ++ return result; ++ } #endif + return result / oss->frame_bytes; + } +@@ -97,11 +109,19 @@ static snd_pcm_sframes_t oss_read(snd_pc + size *= oss->frame_bytes; + result = read(oss->fd, buf, size); + #ifdef __FreeBSD__ +- if (result == -1) +- return -errno; ++ if (result == -1) { ++ if (errno == EAGAIN) ++ return 0; ++ else ++ return -errno; ++ } + #else +- if (result <= 0) +- return result; ++ if (result <= 0) { ++ if (result == -EAGAIN) ++ return 0; ++ else ++ return result; ++ } + #endif + return result / oss->frame_bytes; + } +@@ -258,10 +278,29 @@ static int oss_drain(snd_pcm_ioplug_t *i + #endif if (io->stream == SND_PCM_STREAM_PLAYBACK) - ioctl(oss->fd, SNDCTL_DSP_SYNC); @@ -21,7 +69,29 @@ return 0; } -@@ -272,7 +276,7 @@ static int oss_prepare(snd_pcm_ioplug_t ++static int oss_delay(snd_pcm_ioplug_t *io, snd_pcm_sframes_t *delayp) ++{ ++ snd_pcm_oss_t *oss = io->private_data; ++ int tmp; ++ ++ if (oss->fd < 0) ++ return -EBADFD; ++ ++ if (io->stream == SND_PCM_STREAM_PLAYBACK) { ++ if (ioctl(oss->fd, SNDCTL_DSP_GETODELAY, &tmp) < 0 || tmp < 0) ++ tmp = 0; ++ } else { ++ tmp = 0; ++ } ++ *delayp = snd_pcm_bytes_to_frames(io->pcm, tmp); ++ ++ return (0); ++} ++ + #ifndef __FreeBSD__ + static int oss_prepare(snd_pcm_ioplug_t *io) + { +@@ -272,7 +311,7 @@ static int oss_prepare(snd_pcm_ioplug_t fprintf(stderr, "%s()\n", __func__); #endif @@ -30,3 +100,56 @@ tmp = io->channels; if (ioctl(oss->fd, SNDCTL_DSP_CHANNELS, &tmp) < 0) { +@@ -380,20 +419,26 @@ static int oss_hw_params(snd_pcm_ioplug_ + + ioctl(oss->fd, SNDCTL_DSP_RESET); + +-#define blksz_aligned() ((1 << blksz_shift) - \ +- ((1 << blksz_shift) % oss->frame_bytes)) +- blksz_shift = 16; +- tmp = io->period_size * oss->frame_bytes; ++ /* use a 16ms HW buffer by default */ ++ tmp = ((16 * io->rate) / 1000) * oss->frame_bytes; + +- while (blksz_shift > 4 && blksz_aligned() > tmp) +- blksz_shift--; ++ /* round up to nearest power of two */ ++ while (tmp & (tmp - 1)) ++ tmp += tmp & ~(tmp - 1); ++ ++ /* get logarithmic value */ ++ for (blksz_shift = 0; blksz_shift < 24; blksz_shift++) { ++ if (tmp == (1 << blksz_shift)) ++ break; ++ } + +- blkcnt = 2; + tmp = io->buffer_size * oss->frame_bytes; + +- while (blkcnt < 4096 && (blksz_aligned() * blkcnt) < tmp && +- ((1 << blksz_shift) * blkcnt) < 131072) +- blkcnt <<= 1; ++ /* compute HW buffer big enough to hold SW buffer */ ++ for (blkcnt = FREEBSD_OSS_BLKCNT_MIN; blkcnt != FREEBSD_OSS_BLKCNT_MAX; blkcnt *= 2) { ++ if ((blkcnt << blksz_shift) >= tmp) ++ break; ++ } + + tmp = blksz_shift | (blkcnt << 16); + if (ioctl(oss->fd, SNDCTL_DSP_SETFRAGMENT, &tmp) < 0) { +@@ -767,6 +812,7 @@ static const snd_pcm_ioplug_callback_t o + .prepare = oss_prepare, + #endif + .drain = oss_drain, ++ .delay = oss_delay, + }; + + static const snd_pcm_ioplug_callback_t oss_capture_callback = { +@@ -780,6 +826,7 @@ static const snd_pcm_ioplug_callback_t o + .prepare = oss_prepare, + #endif + .drain = oss_drain, ++ .delay = oss_delay, + }; + +