Hi.

Niko Kiirala wrote:
The curlpit is Timidity ALSA sequencer interface. Examining the source
code, I created the following patch, which should disable this polling,
when it's not needed.
Maybe something like the attached patch
can do instead? I haven't tested, but it
seems in case of (ctxp->active && IS_STREAM_TRACE)
the select() is never executed at all, so
100% of CPU will be consumed no matter what.
I did such a patch for the server interface,
and it was applied. Of course it doesn't
make it inevitably correct, but noone complained
since, and consuming 100% of CPU is certainly
unacceptable.
Though for the server interface I managed to
reduce the CPU usage much further with a few
simple tricks.

--- alsaseq_c.c.old	2006-12-14 23:05:19.000000000 +0300
+++ alsaseq_c.c	2007-07-05 22:21:55.000000000 +0400
@@ -501,6 +501,8 @@
 
 static void doit(struct seq_context *ctxp)
 {
+	fd_set rfds;
+	struct timeval timeout;
 	for (;;) {
 		while (snd_seq_event_input_pending(ctxp->handle, 1)) {
 			if (do_sequencer(ctxp))
@@ -528,15 +530,17 @@
 			play_event(&ev);
 			aq_fill_nonblocking();
 		}
-		if (! ctxp->active || ! IS_STREAM_TRACE) {
-			fd_set rfds;
-			struct timeval timeout;
-			FD_ZERO(&rfds);
-			FD_SET(ctxp->fd, &rfds);
+
+		FD_ZERO(&rfds);
+		FD_SET(ctxp->fd, &rfds);
+		if (ctxp->active) {
 			timeout.tv_sec = 0;
 			timeout.tv_usec = 10000; /* 10ms */
 			if (select(ctxp->fd + 1, &rfds, NULL, NULL, &timeout) < 0)
 				goto __done;
+		} else {
+			if (select(ctxp->fd + 1, &rfds, NULL, NULL, NULL) < 0)
+				goto __done;
 		}
 	}
 
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Timidity-talk mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/timidity-talk

Reply via email to