diff options
author | tijl <tijl@FreeBSD.org> | 2014-10-28 22:09:01 +0800 |
---|---|---|
committer | tijl <tijl@FreeBSD.org> | 2014-10-28 22:09:01 +0800 |
commit | 3417e7ad86d3a694b543094724be63eeefe4e36c (patch) | |
tree | 5e19de6caaf8488a3ac5303e0b0957eba4a35d8f /net | |
parent | d9dbd211c28f3becb9584c5a9f72cf0a8e9c21de (diff) | |
download | freebsd-ports-gnome-3417e7ad86d3a694b543094724be63eeefe4e36c.tar.gz freebsd-ports-gnome-3417e7ad86d3a694b543094724be63eeefe4e36c.tar.zst freebsd-ports-gnome-3417e7ad86d3a694b543094724be63eeefe4e36c.zip |
Further reduce latency in the OSS support
PR: 194346
Submitted by: hselasky
Diffstat (limited to 'net')
-rw-r--r-- | net/mediastreamer/Makefile | 2 | ||||
-rw-r--r-- | net/mediastreamer/files/patch-src__audiofilters__oss.c | 82 |
2 files changed, 82 insertions, 2 deletions
diff --git a/net/mediastreamer/Makefile b/net/mediastreamer/Makefile index a87b9a272857..0ce421dd2c06 100644 --- a/net/mediastreamer/Makefile +++ b/net/mediastreamer/Makefile @@ -3,7 +3,7 @@ PORTNAME= mediastreamer PORTVERSION= 2.10.0 -PORTREVISION= 6 +PORTREVISION= 7 CATEGORIES= net MASTER_SITES= SAVANNAH/linphone/mediastreamer diff --git a/net/mediastreamer/files/patch-src__audiofilters__oss.c b/net/mediastreamer/files/patch-src__audiofilters__oss.c index 11848d059f9e..5fea0a3a6f61 100644 --- a/net/mediastreamer/files/patch-src__audiofilters__oss.c +++ b/net/mediastreamer/files/patch-src__audiofilters__oss.c @@ -1,6 +1,86 @@ --- src/audiofilters/oss.c.orig +++ src/audiofilters/oss.c -@@ -364,7 +364,11 @@ +@@ -41,7 +41,7 @@ + { + int p=0,cond=0; + int i=0; +- int min_size=0,blocksize=512; ++ int min_size=0, blocksize=0; + int err; + + //g_message("opening sound device"); +@@ -77,54 +77,18 @@ + if (err<0){ + ms_warning("oss_open: can't set mono/stereo mode:%s.",strerror(errno)); + } +- +- if (rate==16000) blocksize=4096; /* oss emulation is not very good at 16khz */ +- else blocksize=blocksize*(rate/8000); + + ioctl(fd, SNDCTL_DSP_GETBLKSIZE, &min_size); + +- /** +- * first try SNDCTL_DSP_SETFRAGMENT +- */ +- if (min_size>blocksize) { +- int size_selector=0; +- while ((blocksize >> size_selector) != 1)size_selector++; /*compute selector blocksize = 1<< size_selector*/ +- int frag = (2 << 16) | (size_selector); +- if (ioctl(fd, SNDCTL_DSP_SETFRAGMENT, &frag) == -1) { +- ms_warning("This OSS driver does not support trying SNDCTL_DSP_SETFRAGMENT"); +- ioctl(fd, SNDCTL_DSP_GETBLKSIZE, &min_size); +- +- /* try to subdivide BLKSIZE to reach block size if necessary */ +- if (min_size>blocksize) +- { +- cond=1; +- p=min_size/blocksize; +- while(cond) +- { +- i=ioctl(fd, SNDCTL_DSP_SUBDIVIDE, &p); +- ms_message("subdivide bloc min_size [%i] block_size [%i] said error=%i,errno=%i\n",min_size,blocksize,i,errno); +- if ((i!=0) || (p==1)) cond=0; +- else p=p/2; +- } +- } +- ioctl(fd, SNDCTL_DSP_GETBLKSIZE, &min_size); +- } else { +- /*it's working*/ +- min_size=1 << (frag&0x0FFFF); +- ms_message("Max fragment=%x, size selector=%x block size=%i",frag>>16,frag&0x0FFFF,min_size); +- } +- } +- +- if (min_size>blocksize) +- { +- ms_warning("dsp block size set to %i.",min_size); +- }else{ +- /* no need to access the card with less latency than needed*/ +- min_size=blocksize; +- } ++ /* compute 20ms buffer */ ++ blocksize = (rate / 50) * 2; ++ if (stereo) ++ blocksize *= 2; ++ if (min_size > blocksize) ++ blocksize = min_size; + + ms_message("/dev/dsp opened: rate=%i,bits=%i,stereo=%i blocksize=%i.", +- rate,bits,stereo,min_size); ++ rate,bits,stereo,blocksize); + + /* start recording !!! Alex */ + { +@@ -134,7 +98,7 @@ + res=ioctl(fd, SNDCTL_DSP_SETTRIGGER, &fl); + if (res<0) ms_warning("OSS_TRIGGER: %s",strerror(errno)); + } +- *minsz=min_size; ++ *minsz=blocksize; + return fd; + } + +@@ -364,7 +328,11 @@ } } if (d->pcmfd_write>=0){ |