jacksonlcrews / darkice

Automatically exported from code.google.com/p/darkice
0 stars 0 forks source link

Darkice could crash system while reading from /dev/dsp when device disconnects (usb tuners) #48

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Insert USB tuner with dsp support
2. Start darkice on device
3. Disconnect USB device, system is not responding anymore

System stop responding while reading from device.

file: OssDspSource.cpp
line: 288
code: ret = ::read( fileDescriptor, buf, len);

I tried kernel 2.6.33.2 and 2.6.37.3 with same behaviour.

Only possible solution i have found is to use NON BLOCKING reading from device 
and disconnect when reading limit amount of zero size returns.

Patch is attached in file, but it is not ready for merging, it is just example.

Original issue reported on code.google.com by thunder....@gmail.com on 15 Mar 2011 at 10:30

Attachments:

GoogleCodeExporter commented 9 years ago
I do not agree with the solution.
It might work for you, but busy looping on a read is never efficient.
If the machine is fast enough it might loop many times without reading a single 
byte, as machines get faster you must increase your loop counter.... bad design

If you must disconnect the sound card ? Why do it ?
Then use other solution please, check return value of read() must be -1 and 
check errno for problems
Also use select() to wait for data to become ready or timeout at about 0.2 
second, if nothing available then assume the device failed.
Just my opinion...

Original comment by oetelaar.automatisering on 16 Mar 2011 at 11:50

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
USB sound cards (tuner) sometimes just resets and device is lost for about 5 
seconds, sometimes it change /dev/dspX to /dev/dspY after reseting USB device.

System jusg hangs while reading from device in non-blocking mode, so I can't 
check return value, becasue read is running forever, the same behaviour is for 
NON BLOCKING reading, normal reading has for example 10 null readings 11. is 
data and reading whit disconnected device hase for example 30 null readings, 
31. is system crash (so there is time to catch it).

I wrote my own program for recording and streaming in C and it is stable, there 
is no system crash, but it doesn't using more threads.

I don't know why darkice crashed, can someone else test this issue?

Original comment by thunder....@gmail.com on 16 Mar 2011 at 8:46

GoogleCodeExporter commented 9 years ago
Using select() could be a good choice.
I don't think we really have a problem here...

Original comment by rafael2k...@gmail.com on 16 Jan 2012 at 9:34