summaryrefslogtreecommitdiffstats
path: root/src/plugins/sensors/blackberry
diff options
context:
space:
mode:
authorThomas McGuire <thomas.mcguire.qnx@kdab.com>2012-07-09 14:15:59 +0200
committerQt by Nokia <qt-info@nokia.com>2012-07-12 02:28:35 +0200
commit5464963f9afae3bf7329d9b0ea7102231125f794 (patch)
tree840eaf19cea84d2185105272a651dc1675130731 /src/plugins/sensors/blackberry
parenta355c3a54cdc1c8bfd2129307c7824dd7012bd11 (diff)
Blackberry: Implement buffering
The API provided by QSensor does not fit nicely for what the OS service API provides. Instead of adding yet another buffer-related property to QSensor, I added documentation to QSensor describing the differences in behaviour. Change-Id: I2d81d9c62ce7e8b50c27631a28aa7fbcaca70373 Reviewed-by: Adam Parco <aparco@rim.com> Reviewed-by: Lorn Potter <lorn.potter@nokia.com>
Diffstat (limited to 'src/plugins/sensors/blackberry')
-rw-r--r--src/plugins/sensors/blackberry/bbsensorbackend.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/plugins/sensors/blackberry/bbsensorbackend.cpp b/src/plugins/sensors/blackberry/bbsensorbackend.cpp
index 7a8a2933..c13bc585 100644
--- a/src/plugins/sensors/blackberry/bbsensorbackend.cpp
+++ b/src/plugins/sensors/blackberry/bbsensorbackend.cpp
@@ -45,6 +45,7 @@
#include <fcntl.h>
static const int microSecondsPerSecond = 1000 * 1000;
+static const int defaultBufferSize = 10;
static int microSecondsToHertz(uint microSeconds)
{
@@ -62,6 +63,10 @@ BbSensorBackendBase::BbSensorBackendBase(const QString &devicePath, sensor_type_
{
QCoreApplication::instance()->installEventFilter(this);
connect(sensor, SIGNAL(alwaysOnChanged()), this, SLOT(applyAlwaysOnProperty()));
+
+ // Set some sensible default values
+ sensor->setProperty("efficientBufferSize", defaultBufferSize);
+ sensor->setProperty("maxBufferSize", defaultBufferSize);
}
QFile &BbSensorBackendBase::deviceFile()
@@ -169,6 +174,24 @@ void BbSensorBackendBase::start()
return;
}
+ // Activate event queuing if needed
+ bool ok = false;
+ const int requestedBufferSize = sensor()->property("bufferSize").toInt(&ok);
+ if (ok && requestedBufferSize > 1) {
+ sensor_devctl_queue_u queueControl;
+ queueControl.tx.enable = 1;
+ const int result = devctl(m_deviceFile.handle(), DCMD_SENSOR_QUEUE, &queueControl, sizeof(queueControl), NULL);
+ if (result != EOK) {
+ perror(QString::fromLatin1("Enabling sensor queuing for %1 failed")
+ .arg(m_deviceFile.fileName()).toLocal8Bit());
+ }
+
+ const int actualBufferSize = queueControl.rx.size;
+ sensor()->setProperty("bufferSize", actualBufferSize);
+ sensor()->setProperty("efficientBufferSize", actualBufferSize);
+ sensor()->setProperty("maxBufferSize", actualBufferSize);
+ }
+
applyAlwaysOnProperty();
m_socketNotifier.reset(new QSocketNotifier(m_deviceFile.handle(), QSocketNotifier::Read));