From owner-svn-ports-all@freebsd.org Mon Sep 23 07:08:23 2019 Return-Path: Delivered-To: svn-ports-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 5466AE9076; Mon, 23 Sep 2019 07:08:23 +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 46cFlq1X0hz4dXx; Mon, 23 Sep 2019 07:08:23 +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 EDD9CB2CA; Mon, 23 Sep 2019 07:08:22 +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 x8N78Mqd059939; Mon, 23 Sep 2019 07:08:22 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x8N78MKF059937; Mon, 23 Sep 2019 07:08:22 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <201909230708.x8N78MKF059937@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Mon, 23 Sep 2019 07:08:22 +0000 (UTC) To: ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org Subject: svn commit: r512612 - in head/multimedia/mplayer: . files X-SVN-Group: ports-head X-SVN-Commit-Author: hselasky X-SVN-Commit-Paths: in head/multimedia/mplayer: . files X-SVN-Commit-Revision: 512612 X-SVN-Commit-Repository: ports MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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: Mon, 23 Sep 2019 07:08:23 -0000 Author: hselasky Date: Mon Sep 23 07:08:22 2019 New Revision: 512612 URL: https://svnweb.freebsd.org/changeset/ports/512612 Log: Fix OSS audio playback of some videos after SVN r351847. Make sure mplayer sets a sensible fragment and buffer size. Discussed with: riggs@ Tested by: naddy@ Approved by: pi Modified: head/multimedia/mplayer/Makefile head/multimedia/mplayer/files/patch-libao2_ao__oss.c Modified: head/multimedia/mplayer/Makefile ============================================================================== --- head/multimedia/mplayer/Makefile Mon Sep 23 06:20:40 2019 (r512611) +++ head/multimedia/mplayer/Makefile Mon Sep 23 07:08:22 2019 (r512612) @@ -3,7 +3,7 @@ PORTNAME= mplayer PORTVERSION= ${MPLAYER_PORT_VERSION}.${MPLAYER_SNAPSHOT_DATE:S/-//g} -PORTREVISION= 2 +PORTREVISION= 3 CATEGORIES= multimedia audio MAINTAINER= riggs@FreeBSD.org Modified: head/multimedia/mplayer/files/patch-libao2_ao__oss.c ============================================================================== --- head/multimedia/mplayer/files/patch-libao2_ao__oss.c Mon Sep 23 06:20:40 2019 (r512611) +++ head/multimedia/mplayer/files/patch-libao2_ao__oss.c Mon Sep 23 07:08:22 2019 (r512612) @@ -33,7 +33,64 @@ #endif #ifdef AFMT_U32_LE case AFMT_U32_LE: return AF_FORMAT_U32_LE; -@@ -441,10 +453,30 @@ static void uninit(int immed){ +@@ -217,6 +229,48 @@ static int control(int cmd,void *arg){ + return CONTROL_UNKNOWN; + } + ++static void setfragment(int audio_fd) ++{ ++ int buffer_bytes = ao_data.channels * ao_data.samplerate; ++ int block_size = 0; ++ ++ switch (ao_data.format & AF_FORMAT_BITS_MASK) { ++ case AF_FORMAT_8BIT: ++ break; ++ case AF_FORMAT_16BIT: ++ buffer_bytes *= 2; ++ break; ++ case AF_FORMAT_24BIT: ++ buffer_bytes *= 3; ++ break; ++ case AF_FORMAT_32BIT: ++ buffer_bytes *= 4; ++ break; ++ } ++ buffer_bytes *= 0.050; ++ ++ if(ioctl(audio_fd, SNDCTL_DSP_GETBLKSIZE, &block_size)==0){ ++ int setfrag; ++ /* make block size power of two */ ++ while (block_size & (block_size - 1)) ++ block_size += block_size & ~(block_size - 1); ++ /* set number of fragments */ ++ setfrag = ((buffer_bytes + block_size - 1) / block_size) << 16; ++ /* need at least double buffering */ ++ if (setfrag < (2 << 16)) ++ setfrag = (2 << 16); ++ /* set block size in power of two */ ++ while (block_size) { ++ setfrag++; ++ block_size /= 2; ++ } ++ /* try to set a total buffer of 50ms */ ++ if (ioctl(audio_fd, SNDCTL_DSP_SETFRAGMENT, &setfrag)==-1){ ++ mp_msg(MSGT_AO,MSGL_V,"audio_setup: setfragment %d failed\n", setfrag); ++ } ++ } ++} ++ + // open & setup audio device + // return: 1=success 0=fail + static int init(int rate,int channels,int format,int flags){ +@@ -364,6 +418,7 @@ ac3_retry: + mp_msg(MSGT_AO,MSGL_WARN, "OSS: Failed setting sample-rate %i %s\n", rate, strerror(errno)); + mp_msg(MSGT_AO,MSGL_V,"audio_setup: using %d Hz samplerate (requested: %d)\n",ao_data.samplerate,rate); + } ++ setfragment(audio_fd); + + if(ioctl(audio_fd, SNDCTL_DSP_GETOSPACE, &zz)==-1){ + int r=0; +@@ -441,10 +496,30 @@ static void uninit(int immed){ audio_fd = -1; } @@ -64,7 +121,7 @@ uninit(1); audio_fd=open(dsp, O_WRONLY); if(audio_fd < 0){ -@@ -456,6 +488,7 @@ static void reset(void){ +@@ -456,6 +531,7 @@ static void reset(void){ fcntl(audio_fd, F_SETFD, FD_CLOEXEC); #endif @@ -72,13 +129,14 @@ oss_format = format2oss(ao_data.format); if(AF_FORMAT_IS_AC3(ao_data.format)) fail |= ioctl (audio_fd, SNDCTL_DSP_SPEED, &ao_data.samplerate) == -1; -@@ -467,14 +500,14 @@ static void reset(void){ +@@ -467,14 +543,15 @@ static void reset(void){ int c = ao_data.channels-1; fail |= ioctl (audio_fd, SNDCTL_DSP_STEREO, &c) == -1; } - fail |= ioctl (audio_fd, SNDCTL_DSP_SPEED, &ao_data.samplerate) == -1; } - mp_msg(MSGT_AO,MSGL_WARN, "OSS: Reset failed\n"); ++ setfragment(audio_fd); + restorevol(); }