From nobody Fri Dec 31 10:00:32 2021 X-Original-To: dev-commits-ports-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 56EE919152FA; Fri, 31 Dec 2021 10:00:33 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4JQLHP0h4mz3Pmk; Fri, 31 Dec 2021 10:00:33 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id E152F1541; Fri, 31 Dec 2021 10:00:32 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1BVA0Whh089057; Fri, 31 Dec 2021 10:00:32 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1BVA0WkW089056; Fri, 31 Dec 2021 10:00:32 GMT (envelope-from git) Date: Fri, 31 Dec 2021 10:00:32 GMT Message-Id: <202112311000.1BVA0WkW089056@gitrepo.freebsd.org> To: ports-committers@FreeBSD.org, dev-commits-ports-all@FreeBSD.org, dev-commits-ports-main@FreeBSD.org From: Hans Petter Selasky Subject: git: c6218ed82612 - main - www/firefox: Force 32 ms service intervals at most for the CUBEB OSS backend. List-Id: Commit messages for all branches of the ports repository List-Archive: https://lists.freebsd.org/archives/dev-commits-ports-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-ports-all@freebsd.org X-BeenThere: dev-commits-ports-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: hselasky X-Git-Repository: ports X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: c6218ed826128b021740bbd416ab4e0eb35fc108 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1640944833; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=molsybhnDRUySbzreyYWRnvg+98rczg4lmVDl2aYtnI=; b=IQOw88NCyx/gEbXvQ5GL9vrfqUHenSqaP3qaoDalN/2feLt+1ce/l+XFuyam8jlkRXyHb9 DXxXZ03Wbh50LJ+yPvrsgkNSFetkE32uY76vviPKqC/U48BvTNXFsShCzPknylKePGlUj4 QsOIDsL+jkiole+up2uhRLmEvIHfDT7j2QS/4L3H/Mlno/ckZSX5jpxdr1LYEK4YaOk8An sOnwKec5gpHq0ugkmkuNNJuHGl+4SkCpJXYiH466k28k2OVM2eGAfTxn+ZqTezKxmYwZx4 ghNSIoAnVswdirhC0TXuLMI6sz0o6DWBgDi6afU6Z8fAzC+eJahsGW2I5FXTVg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1640944833; a=rsa-sha256; cv=none; b=EuLz8IdBQVDRLESY9nDyTskuZ6bcYuC57zqkk7aqmLql4/4tHw3joS229Z0L2D/VogRXSb JW9wuB2Z1ut+0vaH7znsitimGvT2eH9L1Wf0T6XWrnKwbA27WfWorOzvqsgbKTx0/DFUX1 AedJsen8Eu2FMS/Z0XlHfHEdGt1wmIlNNg3TLlC3tZKRCWLiIbg+oxvcl4tzSs72oSt/3i 8ew1Az+BZRvcSfgRQobl2VvRKHC+g6mR/WjDPAdBrdCcbAmMHV8XOaweVjWz08bTBWPE49 B6GpuWtXv4wzn2mGIZLVBhKiXwwk615z773wvMGLs6+qdhLEU44Fu6HaM2sTIQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by hselasky: URL: https://cgit.FreeBSD.org/ports/commit/?id=c6218ed826128b021740bbd416ab4e0eb35fc108 commit c6218ed826128b021740bbd416ab4e0eb35fc108 Author: Hans Petter Selasky AuthorDate: 2021-12-27 09:35:09 +0000 Commit: Hans Petter Selasky CommitDate: 2021-12-31 10:00:02 +0000 www/firefox: Force 32 ms service intervals at most for the CUBEB OSS backend. Sometimes a big buffer may be specified by CUBEB. Feed big buffers in smaller chunks to avoid issues with the audio flow. Other CUBEB audio backends apparently do the same. Fixes audio out of sync for youtube videos. The need for this patch will eventually go away as the changes are upstreamed. PR: 260620 Approved by: pi (implicit) --- www/firefox/Makefile | 1 + .../files/patch-media_libcubeb_src_cubeb__oss.c | 59 +++++++++++++--------- 2 files changed, 37 insertions(+), 23 deletions(-) diff --git a/www/firefox/Makefile b/www/firefox/Makefile index a9fb6d5efd76..e3cec497f389 100644 --- a/www/firefox/Makefile +++ b/www/firefox/Makefile @@ -2,6 +2,7 @@ PORTNAME= firefox DISTVERSION= 95.0.2 +PORTREVISION= 1 PORTEPOCH= 2 CATEGORIES= www MASTER_SITES= MOZILLA/${PORTNAME}/releases/${DISTVERSION}/source \ diff --git a/www/firefox/files/patch-media_libcubeb_src_cubeb__oss.c b/www/firefox/files/patch-media_libcubeb_src_cubeb__oss.c index 2449fa3d4195..5ba28fea536b 100644 --- a/www/firefox/files/patch-media_libcubeb_src_cubeb__oss.c +++ b/www/firefox/files/patch-media_libcubeb_src_cubeb__oss.c @@ -1,14 +1,15 @@ ---- media/libcubeb/src/cubeb_oss.c.orig 2021-11-29 14:01:19 UTC +--- media/libcubeb/src/cubeb_oss.c.orig 2021-12-18 20:36:16 UTC +++ media/libcubeb/src/cubeb_oss.c -@@ -96,6 +96,7 @@ struct oss_stream { +@@ -96,6 +96,8 @@ struct oss_stream { oss_devnode_t name; int fd; void * buf; + unsigned int bufframes; ++ unsigned int maxframes; struct stream_info { int channels; -@@ -126,9 +127,6 @@ struct cubeb_stream { +@@ -126,9 +128,6 @@ struct cubeb_stream { cubeb_data_callback data_cb; cubeb_state_callback state_cb; uint64_t frames_written /* (m) */; @@ -18,7 +19,7 @@ }; static char const * -@@ -786,40 +784,72 @@ oss_put_play_frames(cubeb_stream * s, unsigned int nfr +@@ -786,40 +785,72 @@ oss_put_play_frames(cubeb_stream * s, unsigned int nfr } static int @@ -84,9 +85,9 @@ + pfds[0].fd = s->play.fd; + pfds[1].fd = -1; + goto retry; -+ } else if (tnfr > (long)s->play.bufframes) { ++ } else if (tnfr > (long)s->play.maxframes) { + /* too many frames available - limit */ -+ tnfr = (long)s->play.bufframes; ++ tnfr = (long)s->play.maxframes; + } + if (nfr > tnfr) { + nfr = tnfr; @@ -102,9 +103,9 @@ + pfds[0].fd = -1; + pfds[1].fd = s->record.fd; + goto retry; -+ } else if (tnfr > (long)s->record.bufframes) { ++ } else if (tnfr > (long)s->record.maxframes) { + /* too many frames available - limit */ -+ tnfr = (long)s->record.bufframes; ++ tnfr = (long)s->record.maxframes; + } + if (nfr > tnfr) { + nfr = tnfr; @@ -115,7 +116,7 @@ return 0; } -@@ -840,7 +870,7 @@ oss_audio_loop(cubeb_stream * s, cubeb_state * new_sta +@@ -840,7 +871,7 @@ oss_audio_loop(cubeb_stream * s, cubeb_state * new_sta } trig |= PCM_ENABLE_INPUT; @@ -124,7 +125,7 @@ if (ioctl(s->record.fd, SNDCTL_DSP_SETTRIGGER, &trig) == -1) { LOG("Error %d occured when setting trigger on record fd", errno); -@@ -877,6 +907,7 @@ oss_audio_loop(cubeb_stream * s, cubeb_state * new_sta +@@ -877,6 +908,7 @@ oss_audio_loop(cubeb_stream * s, cubeb_state * new_sta oss_linear32_to_float(s->record.buf, s->record.info.channels * nfr); } } @@ -132,7 +133,7 @@ got = s->data_cb(s, s->user_ptr, s->record.buf, s->play.buf, nfr); if (got == CUBEB_ERROR) { state = CUBEB_STATE_ERROR; -@@ -920,45 +951,10 @@ oss_audio_loop(cubeb_stream * s, cubeb_state * new_sta +@@ -920,45 +952,10 @@ oss_audio_loop(cubeb_stream * s, cubeb_state * new_sta } } @@ -181,7 +182,7 @@ } return 1; -@@ -1015,9 +1011,10 @@ static inline int +@@ -1015,9 +1012,10 @@ static inline int oss_calc_frag_shift(unsigned int frames, unsigned int frame_size) { int n = 4; @@ -194,7 +195,7 @@ return n; } -@@ -1037,7 +1034,6 @@ oss_stream_init(cubeb * context, cubeb_stream ** strea +@@ -1037,7 +1035,6 @@ oss_stream_init(cubeb * context, cubeb_stream ** strea cubeb_state_callback state_callback, void * user_ptr) { int ret = CUBEB_OK; @@ -202,7 +203,7 @@ cubeb_stream * s = NULL; const char * defdsp; -@@ -1051,7 +1047,6 @@ oss_stream_init(cubeb * context, cubeb_stream ** strea +@@ -1051,7 +1048,6 @@ oss_stream_init(cubeb * context, cubeb_stream ** strea } s->state = CUBEB_STATE_STOPPED; s->record.fd = s->play.fd = -1; @@ -210,7 +211,7 @@ if (input_device != NULL) { strlcpy(s->record.name, input_device, sizeof(s->record.name)); } else { -@@ -1064,6 +1059,8 @@ oss_stream_init(cubeb * context, cubeb_stream ** strea +@@ -1064,6 +1060,8 @@ oss_stream_init(cubeb * context, cubeb_stream ** strea } if (input_stream_params != NULL) { unsigned int nb_channels; @@ -219,7 +220,7 @@ if (input_stream_params->prefs & CUBEB_STREAM_PREF_LOOPBACK) { LOG("Loopback not supported"); ret = CUBEB_ERROR_NOT_SUPPORTED; -@@ -1077,13 +1074,11 @@ oss_stream_init(cubeb * context, cubeb_stream ** strea +@@ -1077,13 +1075,11 @@ oss_stream_init(cubeb * context, cubeb_stream ** strea ret = CUBEB_ERROR_INVALID_PARAMETER; goto error; } @@ -238,7 +239,7 @@ } if ((ret = oss_copy_params(s->record.fd, s, input_stream_params, &s->record.info)) != CUBEB_OK) { -@@ -1094,11 +1089,17 @@ oss_stream_init(cubeb * context, cubeb_stream ** strea +@@ -1094,11 +1090,17 @@ oss_stream_init(cubeb * context, cubeb_stream ** strea (input_stream_params->format == CUBEB_SAMPLE_FLOAT32NE); s->record.frame_size = s->record.info.channels * (s->record.info.precision / 8); @@ -258,7 +259,7 @@ if (output_stream_params->prefs & CUBEB_STREAM_PREF_LOOPBACK) { LOG("Loopback not supported"); ret = CUBEB_ERROR_NOT_SUPPORTED; -@@ -1113,13 +1114,11 @@ oss_stream_init(cubeb * context, cubeb_stream ** strea +@@ -1113,13 +1115,11 @@ oss_stream_init(cubeb * context, cubeb_stream ** strea ret = CUBEB_ERROR_INVALID_PARAMETER; goto error; } @@ -277,7 +278,7 @@ } if ((ret = oss_copy_params(s->play.fd, s, output_stream_params, &s->play.info)) != CUBEB_OK) { -@@ -1128,19 +1127,16 @@ oss_stream_init(cubeb * context, cubeb_stream ** strea +@@ -1128,19 +1128,16 @@ oss_stream_init(cubeb * context, cubeb_stream ** strea } s->play.floating = (output_stream_params->format == CUBEB_SAMPLE_FLOAT32NE); s->play.frame_size = s->play.info.channels * (s->play.info.precision / 8); @@ -305,7 +306,7 @@ if (ioctl(s->play.fd, SNDCTL_DSP_SETFRAGMENT, &frag)) LOG("Failed to set play fd with SNDCTL_DSP_SETFRAGMENT. frag: 0x%x", frag); -@@ -1148,13 +1144,17 @@ oss_stream_init(cubeb * context, cubeb_stream ** strea +@@ -1148,13 +1145,28 @@ oss_stream_init(cubeb * context, cubeb_stream ** strea if (ioctl(s->play.fd, SNDCTL_DSP_GETOSPACE, &bi)) LOG("Failed to get play fd's buffer info."); else { @@ -313,8 +314,19 @@ - s->nfr = bi.fragsize / s->play.frame_size; + s->play.bufframes = (bi.fragsize * bi.fragstotal) / s->play.frame_size; } ++ int lw; + -+ int lw = s->play.frame_size; ++ /* ++ * Force 32 ms service intervals at most, or when recording is ++ * active, use the recording service intervals as a reference. ++ */ ++ s->play.maxframes = (32 * output_stream_params->rate) / 1000; ++ if (s->record.fd != -1 || s->play.maxframes >= s->play.bufframes) { ++ lw = s->play.frame_size; /* Feed data when possible. */ ++ s->play.maxframes = s->play.bufframes; ++ } else { ++ lw = (s->play.bufframes - s->play.maxframes) * s->play.frame_size; ++ } + if (ioctl(s->play.fd, SNDCTL_DSP_LOW_WATER, &lw)) + LOG("Audio device \"%s\" (play) could not set trigger threshold", + s->play.name); @@ -327,7 +339,7 @@ if (ioctl(s->record.fd, SNDCTL_DSP_SETFRAGMENT, &frag)) LOG("Failed to set record fd with SNDCTL_DSP_SETFRAGMENT. frag: 0x%x", frag); -@@ -1162,11 +1162,15 @@ oss_stream_init(cubeb * context, cubeb_stream ** strea +@@ -1162,11 +1174,16 @@ oss_stream_init(cubeb * context, cubeb_stream ** strea if (ioctl(s->record.fd, SNDCTL_DSP_GETISPACE, &bi)) LOG("Failed to get record fd's buffer info."); else { @@ -337,6 +349,7 @@ + (bi.fragsize * bi.fragstotal) / s->record.frame_size; } + ++ s->record.maxframes = s->record.bufframes; + int lw = s->record.frame_size; + if (ioctl(s->record.fd, SNDCTL_DSP_LOW_WATER, &lw)) + LOG("Audio device \"%s\" (record) could not set trigger threshold", @@ -346,7 +359,7 @@ s->context = context; s->volume = 1.0; s->state_cb = state_callback; -@@ -1188,13 +1192,14 @@ oss_stream_init(cubeb * context, cubeb_stream ** strea +@@ -1188,13 +1205,14 @@ oss_stream_init(cubeb * context, cubeb_stream ** strea s->doorbell = false; if (s->play.fd != -1) {