Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 31 Oct 2012 10:37:46 +0100
From:      Hans Petter Selasky <hselasky@c2i.net>
To:        sox-devel@lists.sourceforge.net
Cc:        freebsd-multimedia@freebsd.org, Eric Wong <normalperson@yhbt.net>
Subject:   Re: [SoX-devel] Bug in sox-14.3.2/src/oss.c
Message-ID:  <201210311037.46581.hselasky@c2i.net>
In-Reply-To: <20121031090350.GA8165@dcvr.yhbt.net>
References:  <201210281324.36923.hselasky@c2i.net> <20121031090350.GA8165@dcvr.yhbt.net>

next in thread | previous in thread | raw e-mail | index | archive | help
On Wednesday 31 October 2012 10:03:50 Eric Wong wrote:
> Hans Petter Selasky <hselasky@c2i.net> wrote:
> > Hi,
> > 
> > Line buffering should be off, but this statement leads to SOX reading 1
> > and
> > 
> > one byte from the recording DSP device under FreeBSD:
> >     /* Change to non-buffered I/O */
> >     setvbuf(ft->fp, NULL, _IONBF, sizeof(char) * file->size);
> >     return(SOX_SUCCESS);
> > 
> > I think this flag should be used instead:
> >            _IOFBF  fully buffered
> > 
> > I've tested this change and it works like expected.
> > 
> > Any comments?
> 
> The code you're changing in src/oss.c no long applies to SoX 14.4.0,
> how does 14.4.0 work out-of-the-box for you?
> 

Hi,

First observation:

oss.c: In function 'ossinit':
oss.c:116: warning: dereferencing 'void *' pointer
oss.c:116: error: request for member '_file' in something not a structure or 
union
oss.c:124: warning: dereferencing 'void *' pointer
oss.c:124: error: request for member '_file' in something not a structure or 
union
oss.c:163: warning: dereferencing 'void *' pointer
oss.c:163: error: request for member '_file' in something not a structure or 
union
oss.c:176: warning: dereferencing 'void *' pointer
oss.c:176: error: request for member '_file' in something not a structure or 
union
oss.c:186: warning: dereferencing 'void *' pointer
oss.c:186: error: request for member '_file' in something not a structure or 
union
oss.c:205: warning: dereferencing 'void *' pointer
oss.c:205: error: request for member '_file' in something not a structure or 
union
oss.c:214: warning: dereferencing 'void *' pointer
oss.c:214: error: request for member '_file' in something not a structure or 
union

Fixed by renaming fileno( into sox_fileno( and defining this:

#define sox_fileno(x) fileno((FILE *)(x))

Second observation:

Default audio driver is not OSS.

env AUDIODEVICE=/dev/dsp AUDIODRIVER=oss rec test.wav

Third observation:

GIO syscalls are still used, and the length is 1 byte.

 15260 sox      RET   read 1
 15260 sox      CALL  read(0x3,0x807b2de37,0x1)
 15260 sox      GIO   fd 3 read 1 byte
       0x0000 ff    

Patch needed:

    /* Change to non-buffered I/O */
    setvbuf(ft->fp, NULL, _IONBF, sizeof(char) * file->size);
    return(SOX_SUCCESS);
}

Change to:

    /* Change to non-buffered I/O */
    setvbuf(ft->fp, NULL, _IOFBF, sizeof(char) * file->size);
    return(SOX_SUCCESS);
}


--HPS



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201210311037.46581.hselasky>