Hi,

The way to do this is to use a select loop. Every time the device
reports that some data is available then read one fragment of it (do not
check how much data there is available). This read may block a fraction
of second but it doesn't matter provided that the fragment size is
reasonably small.

Use of non-blocking I/O is asking for troubles. It is a flow control
method directly from hell.

Best regards,

Hannu
----
Sherwin Soltani wrote:
> Hello,
> 
> I'm using OSS 4.2 on CentOS 5.4, developing a special purpose
> application. In our system we have two PCI audio cards using the
> envy24 driver. In total there are 4 stereo inputs and 4 stereo
> outputs. We want to use this application to control the flow of audio
> data dynamically, by accepting commands over a sockets interface and
> interpreting them to let us switch different inputs to play over
> different outputs.
> 
> I figured this should be pretty easy by simply opening the device
> nodes corresponding to each of the different input channels and output
> channels, then by reading and writing data in a loop. I soon realized
> this approach was a bad idea, because the semantics of read in OSS by
> default block until all data is available.
> 
> Long story short I tried two approaches based on the duplex example in
> the developer's documentation. The first was to use select to wait
> until there was data available, then use ioctl to find out how much
> data was in the input buffers, then do a read on that amount of data
> and redistribute it to the output devices. The second approach was to
> set the devices into non-blocking mode, which I know is not
> recommended, but I make sure the loop doesn't run over the
> interrupts/sec limit.
> 
> In both situations I get this error which seems to stop all progress
> on my console:
> 
> copy_to_user(131072) failed(1)
> osscore: audio: uiomove(UIO_READ) failed
> 
> In my application, I notice the first read from the devices always
> succeeds like I would expect, but every subsequent read after that
> fails with the error "Bad address". The driver error messages and the
> errno correlate, so I'm guessing the second is caused by the first.
> 
> Why is this happening? Is there something odd about full duplexing on
> devices that I need to know, besides the obvious problem which is
> timing? I think I can solve the timing thing by doing what the docs
> suggest, which is writing a few seconds of silence to a device to
> allow input data to buffer up. The latency I don't so much care about,
> although less is better.
> 
> Any help is greatly appreciated. I hope this is the right mailing list
> for this question.
> 

_______________________________________________
oss-devel mailing list
oss-devel@mailman.opensound.com
http://mailman.opensound.com/mailman/listinfo/oss-devel

Reply via email to