[PATCH] limit streamdev client's ringbuffer timeouts to more sane values

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Well, the streamdev-client reads data from a ringbuffer and when there isn't anything
to read it tries to sleep for 1us and loops. This wasn't a problem when the timer
resolution was in the 1000..10000us range (1000..100Hz); the usleep(1) call slept
for one or more milliseconds.
With the high-res timers in kernel 2.6.21+ usleep(1) is no longer treated as
usleep(10000) and the streamdev client is almost unusable; it uses most of the cpu
and causes hundreds of thousands context switches per second.
This gets rid of the almost-busy-loop.

artur

diff -urNp streamdev.org/client/filter.c streamdev/client/filter.c
--- streamdev.org/client/filter.c	2005-11-06 17:43:58.000000000 +0100
+++ streamdev/client/filter.c	2007-04-05 23:25:11.000000000 +0200
@@ -57,6 +57,7 @@ cStreamdevFilters::cStreamdevFilters(voi
 		cThread("streamdev-client: sections assembler") {
 	m_Active = false;
 	m_RingBuffer = new cRingBufferLinear(MEGABYTE(1), TS_SIZE * 2, true);
+	m_RingBuffer->SetTimeouts(10, 10);
 	Start();
 }

@@ -111,8 +112,7 @@ void cStreamdevFilters::Action(void) {
 				}
 			}
 			m_RingBuffer->Del(TS_SIZE);
-		} else
-			usleep(1);
+		}
 	}
 }




[Index of Archives]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Util Linux NG]     [Xfree86]     [Big List of Linux Books]     [Fedora Users]     [Fedora Women]     [ALSA Devel]     [Linux USB]

  Powered by Linux