aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhselasky <hselasky@FreeBSD.org>2019-09-23 15:08:22 +0800
committerhselasky <hselasky@FreeBSD.org>2019-09-23 15:08:22 +0800
commit7443e6e45bd3f843f03a1ce80ebf2e253a02d31d (patch)
treee4fb307eb251c4c1265fe0dfc8dd73a77e9ecd0c
parent3d6988b09b6e007d4705330a632a4511a40e848d (diff)
downloadfreebsd-ports-gnome-7443e6e45bd3f843f03a1ce80ebf2e253a02d31d.tar.gz
freebsd-ports-gnome-7443e6e45bd3f843f03a1ce80ebf2e253a02d31d.tar.zst
freebsd-ports-gnome-7443e6e45bd3f843f03a1ce80ebf2e253a02d31d.zip
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
-rw-r--r--multimedia/mplayer/Makefile2
-rw-r--r--multimedia/mplayer/files/patch-libao2_ao__oss.c64
2 files changed, 62 insertions, 4 deletions
diff --git a/multimedia/mplayer/Makefile b/multimedia/mplayer/Makefile
index 81d1a53e4a9a..650cf8989e66 100644
--- a/multimedia/mplayer/Makefile
+++ b/multimedia/mplayer/Makefile
@@ -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
diff --git a/multimedia/mplayer/files/patch-libao2_ao__oss.c b/multimedia/mplayer/files/patch-libao2_ao__oss.c
index 2fdb9fc632a7..fd7fb8d6fa64 100644
--- a/multimedia/mplayer/files/patch-libao2_ao__oss.c
+++ b/multimedia/mplayer/files/patch-libao2_ao__oss.c
@@ -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();
}