Commit 7e0c696c authored by jehan's avatar jehan

use SNDCTL_DSP_SETFRAGMENT instead of SNDCTL_DSP_SUBDIVIDE

parent bbf27ab7
......@@ -40,7 +40,7 @@ static int configure_fd(int fd, int bits,int stereo, int rate, int *minsz)
{
int p=0,cond=0;
int i=0;
int min_size=0,blocksize=512;
int min_size=0,blocksize=512,size_selector=9/*=512*/;
int err;
//g_message("opening sound device");
......@@ -79,22 +79,39 @@ static int configure_fd(int fd, int bits,int stereo, int rate, int *minsz)
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);
/* try to subdivide BLKSIZE to reach blocksize 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;
/**
* first try SNDCTL_DSP_SETFRAGMENT
*/
if (min_size>blocksize) {
int frag = (2 << 16) | (size_selector);
if (ioctl(fd, SNDCTL_DSP_SETFRAGMENT, &frag) == -1) {
ms_warning("This OSS driver does not support trying subdivise",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);
}
}
ioctl(fd, SNDCTL_DSP_GETBLKSIZE, &min_size);
if (min_size>blocksize)
{
ms_warning("dsp block size set to %i.",min_size);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment