Hi Phil, Thank you for your comments. I am disappointed to say, that the sample code is only one of several methods I have attempted to get working properly. I do attempt to initialise the device prior to calling this function.
It is strange that our tests show the program hanging when trying to close the device. I implemented a version which did not close the device, however the OS had just as little luck in trying to close the handle. If you have any code I could test as an audio 'loopthrough' function I would be most interested. I am keen to get something stable going. Will use O_RDWR in future! Regards, Andrew At 10:32 24/06/2008, "Phil Quiney" wrote: > Hi, > I think your program is not helping by reading too small chunks. > You have not configured the speed of the device, the bits/sample number of > channels etc - so what format is it using by default??? > Your read will block giving plenty of scope for the output under running as > well.... > General advice on audio (initially from a guy at MV) > 1/ Check for available data input before reading (do not do blocking reads). > This is not an issue if you are only doing input but for full duplex it > matters. > 2/ Empty the device by reading as much data as you can. > 3/ Read in multiples of the fragment size. > 4/ Check for available output space before the write - the write will not > block if it can accept the data. > 5/ Write in multiples of the fragment size. > Using the above advice we can usually get several hours of full duplex audio > before it dies. > I can let you have the audio test program(s) we give to customers if you want > to give that a go. > As a final note - if you want the code to be portable across many targets, I > suggest you change the 'open' to be O_RDWR as most OSS audio drivers will > fail to open the second time. > Regards > Phil Q > Phil Quiney, Senior Software Engineer > Trinity Convergence > Cambridge Business Park > Cowley Road > Cambridge CB4 0WZ, UK > T: +44(0)1223-435536 > F: +44(0)1223-435560 > www.trinityconvergence.com > -----Original Message----- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Andrew > Armstrong > Sent: 24 June 2008 10:41 > To: [email protected] > Subject: Buggy Audio Driver > Hi Guys, > I have been playing with the audio driver. All I want to do is a simple > loopthrough function, however, I am finding that the driver locks up quite > randomly when its file handles are being closed. > Has anyone else come up with this issue? I have attached the function I am > playing with, if anyone can replicate the issue I would be most interested. > Sometimes it can run several times with no issue and other times lock-up each > time it is executed. > Regards, > Andrew > void audioloop(unsigned char timesecs) > { > int fdr; > int fdw; > unsigned char buffer[64]; > unsigned char done = 0; > if( (fdr=open("/dev/sound/dsp",O_RDONLY)) { > printf( "Sound Input Port failed!\n"); > } > else > { > if( (fdw=open("/dev/sound/dsp",O_WRONLY)) { > printf( "Sound Output Port failed!\n"); > } > else > { > time(&starttime); > while (done==0) > { > read(fdr,buffer,64); > ioctl(fdr, SOUND_PCM_SYNC, 0); > write(fdw,buffer,64); > if (timesecs > 0) > { > time(¤ttime); > if ((int)(currenttime - starttime) > timesecs) > { > done=1; > } > } > } > close (fdr); > } > printf( "Closing sound port ...\n"); > close (fdw); > printf( "... Done\n"); > } > } > _______________________________________________ > Davinci-linux-open-source mailing list > [email protected] > http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source > _______________________________________________ > Davinci-linux-open-source mailing list > [email protected] > http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source >
_______________________________________________ Davinci-linux-open-source mailing list [email protected] http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source
