public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
* [Bluez-devel] PATCH2/2: bluez-utils - avoid-unnecessary-polls
@ 2007-10-12 12:30 Kai Vehmanen
  2007-10-14  3:21 ` Luiz Augusto von Dentz
  0 siblings, 1 reply; 2+ messages in thread
From: Kai Vehmanen @ 2007-10-12 12:30 UTC (permalink / raw)
  To: bluez-devel

[-- 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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Bluez-devel] PATCH2/2: bluez-utils - avoid-unnecessary-polls
  2007-10-12 12:30 [Bluez-devel] PATCH2/2: bluez-utils - avoid-unnecessary-polls Kai Vehmanen
@ 2007-10-14  3:21 ` Luiz Augusto von Dentz
  0 siblings, 0 replies; 2+ messages in thread
From: Luiz Augusto von Dentz @ 2007-10-14  3:21 UTC (permalink / raw)
  To: BlueZ development

Hi Kai,

On 10/12/07, Kai Vehmanen <kai.vehmanen@nokia.com> wrote:
> 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...

This was done before but I guess for some reason I don't remember
now we remove it in favor of fixed timeout. Thought we should
reconsider it if it has a good impact on CPU load.

-- =

Luiz Augusto von Dentz
Engenheiro de Computa=E7=E3o

-------------------------------------------------------------------------
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/
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-10-14  3:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-10-12 12:30 [Bluez-devel] PATCH2/2: bluez-utils - avoid-unnecessary-polls Kai Vehmanen
2007-10-14  3:21 ` Luiz Augusto von Dentz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox