public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
From: "Kai Vehmanen" <kai.vehmanen@nokia.com>
To: <bluez-devel@lists.sourceforge.net>
Subject: [Bluez-devel] PATCH2/2: bluez-utils - avoid-unnecessary-polls
Date: Fri, 12 Oct 2007 15:30:21 +0300	[thread overview]
Message-ID: <000401c80ccb$a7cb44b0$c72915ac@NOE.Nokia.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 467 bytes --]

Hello again,

here's the second patch to ALSA A2DP plugin in bluez-utils
(see my previous mail).

This patch changes the worker thread poll timeout to be 
calculated according to application chosen period size. 
This allows to decrease the CPU load significantly for those 
applications that do not require an ultra small period
size. Without the patch (poll timeout of 1msec), the system 
call load is pretty heavy...

Br,
-- 
first.surname@nokia.com (Kai Vehmanen)

[-- Attachment #2: patch-kv-bluez-utils-avoid-unnecessary-polls-20071012.txt --]
[-- Type: text/plain, Size: 950 bytes --]

diff -ruN bluez-utils.orig/audio/pcm_bluetooth.c bluez-utils/audio/pcm_bluetooth.c
--- bluez-utils.orig/audio/pcm_bluetooth.c	2007-10-12 15:07:40.000000000 +0300
+++ bluez-utils/audio/pcm_bluetooth.c	2007-10-12 15:04:58.000000000 +0300
@@ -168,12 +168,17 @@
 	double period_time;
 	struct timeval start;
 	struct pollfd fds[2];
+	int poll_timeout;
 
 	fds[0] = data->server;
 	fds[1] = data->stream;
 
 	prev_periods = 0;
 	period_time = 1000000.0 * data->io.period_size / data->io.rate;
+	if (period_time > (int)(MIN_PERIOD_TIME * 1000))
+		poll_timeout = (int)(period_time / 1000.0f);
+	else
+		poll_timeout = MIN_PERIOD_TIME;
 
 	gettimeofday(&start, 0);
 
@@ -214,7 +219,8 @@
 		}
 
 iter_sleep:
-		ret = poll(fds, 2, MIN_PERIOD_TIME);
+		/* sleep up to one period interval */
+		ret = poll(fds, 2, poll_timeout);
 		if (ret < 0) {
 			SNDERR("poll error: %s (%d)", strerror(errno), errno);
 			if (errno != EINTR)

[-- Attachment #3: Type: text/plain, Size: 314 bytes --]

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/

[-- Attachment #4: Type: text/plain, Size: 164 bytes --]

_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel

             reply	other threads:[~2007-10-12 12:30 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-12 12:30 Kai Vehmanen [this message]
2007-10-14  3:21 ` [Bluez-devel] PATCH2/2: bluez-utils - avoid-unnecessary-polls Luiz Augusto von Dentz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='000401c80ccb$a7cb44b0$c72915ac@NOE.Nokia.com' \
    --to=kai.vehmanen@nokia.com \
    --cc=bluez-devel@lists.sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox