Treat POLLHUP as EOF not an error, fixes IVTV (PVR-) recorders failing. Based on patch from ltskinol@gmail.com Fixes #10732
(cherry picked from commit 3d13d795b2ae4a66f4bd3e5bdfd4168c66474282)
Improve DeviceReadBuffer debugging.
(cherry picked from commit 032f290bedb682fff4b2d3c4508f3a715d57bb11)
Use nothrow new[] to allocate buffer in DRB.

This allows us to handle failures to allocate the potentially large
buffers without the program exiting when compiled with exceptions
enabled (the default).
(cherry picked from commit 75e5530925ecf2d4161036ef23b088b9fd4dccb8)
Reduce # number DeviceReadBuffer::Read() calls.

Refs #11252.

This reduces the number of reads per second we make in the stream handlers
utilizing the DRB. It does this by waiting 20 ms for at least dev_read_size
bytes rather than 500 ms for min_read bytes. The device reads are larger
than the minimum read so this actually results in waiting a bit longer
under normal conditions while returning more quickly when we're not getting
data from the device. A win-win.
(cherry picked from commit 6912383b2c0c59df12aa9c8af521200fbe4e585d)
DeviceReadBuffer: Try to optimize some of the busy-waiting.

Wait for readThreshold or 20 milliseconds before returning to the stream
handler.

Move the throttling "sleep" from the stream handler into the DRB run loop.

Original patch by Rune Petersen.
Closes #11252
(cherry picked from commit 4f0bfd9d1eeff9397fe9386b905567b0e499dcb9)
DeviceReadBuffer: Deal with device drivers which segment their internal buffers.

Some device drivers segment their buffers into pieces, and will return at
most one "piece" at a time.  For efficent processing, we may need to process
more than one "piece" during each loop.
(cherry picked from commit bbfdaceeefdbfe37de3fcac49f37ccfda7d2aa6c)
ASIStreamHandler: Detect how many driver buffers are available, and attempt
to read 1/4 of them during each pass in DeviceReadBuffer.
(cherry picked from commit ee5ac3d3adb36f4ac7223cd98ae1ed66048f7388)