[beast] BSE: support nosleep option in null driver which disables g_usleep()
- From: Stefan Westerfeld <stw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [beast] BSE: support nosleep option in null driver which disables g_usleep()
- Date: Thu, 17 Feb 2011 21:21:21 +0000 (UTC)
commit e235103a1f2861a70e4b2c9bde7e9f25904adff0
Author: Stefan Westerfeld <stefan space twc de>
Date: Thu Feb 17 23:07:42 2011 +0100
BSE: support nosleep option in null driver which disables g_usleep()
This option is useful when bsescm is known to run not as RT process, like
for the audio tests.
bse/bsepcmdevice-null.c | 15 ++++++++++++---
1 files changed, 12 insertions(+), 3 deletions(-)
---
diff --git a/bse/bsepcmdevice-null.c b/bse/bsepcmdevice-null.c
index e245f70..aab229f 100644
--- a/bse/bsepcmdevice-null.c
+++ b/bse/bsepcmdevice-null.c
@@ -26,6 +26,7 @@ typedef struct
{
BsePcmHandle handle;
guint busy_us;
+ guint sleep_us;
} NullHandle;
/* --- prototypes --- */
@@ -73,6 +74,10 @@ bse_pcm_device_null_open (BseDevice *device,
handle->check_io = null_device_check_io;
handle->latency = null_device_latency;
null->busy_us = 0;
+ if (n_args == 1 && strcmp (args[0], "nosleep") == 0)
+ null->sleep_us = 0;
+ else
+ null->sleep_us = 10 * 1000;
BSE_PCM_DEVICE (device)->handle = handle;
DEBUG ("NULL: opening PCM readable=%d writable=%d: %s", require_readable, require_writable, bse_error_blurb (BSE_ERROR_NONE));
return BSE_ERROR_NONE;
@@ -123,7 +128,8 @@ null_device_write (BsePcmHandle *handle,
{
null->busy_us = 0;
/* give cpu to other applications (we might run at nice level -20) */
- g_usleep (10 * 1000);
+ if (null->sleep_us)
+ g_usleep (null->sleep_us);
}
}
@@ -136,10 +142,13 @@ bse_pcm_device_null_class_init (BsePcmDeviceNullClass *class)
bse_device_class_setup (device_class,
-1,
"null",
- NULL, /* syntax */
+ _("[nosleep]"), /* syntax */
/* TRANSLATORS: keep this text to 70 chars in width */
_("Discard all PCM output and provide zero blocks as input. This\n"
- "driver is not part of the automatic PCM device selection list."));
+ "driver is not part of the automatic PCM device selection list.\n"
+ "Normally the null driver sleeps regularily to give CPU cycles to\n"
+ "other apps, which is helpful when running at high priority.\n"
+ "Sleeping can be disabled by passing \"nosleep\" as option.\n"));
device_class->open = bse_pcm_device_null_open;
device_class->close = bse_pcm_device_null_close;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]