BControllable: Fix real_time and perf_time mismatch

* It caused parameters to change with delay, because the
event has been enqueued in the event queue with real time.
* Please don't rely on system_time.
* Fixes #5106.
This commit is contained in:
Dario Casalinuovo 2016-04-07 15:57:45 +02:00
parent 15b4841a94
commit f441a1e2ce
2 changed files with 13 additions and 3 deletions

View File

@ -39,6 +39,7 @@
#include <OS.h>
#include <ParameterWeb.h>
#include <Roster.h>
#include <TimeSource.h>
#include <debug.h>
#include <DataExchange.h>
@ -233,7 +234,16 @@ BControllable::HandleMessage(int32 message, const void* data, size_t size)
return B_OK;
}
SetParameterValue(request.parameter_id, request.when,
// NOTE: This is not very fair, but the alternative
// would have been to mess with friends classes and
// member variables.
bigtime_t perfTime = 0;
if (request.when == -1)
perfTime = TimeSource()->Now();
else
perfTime = request.when;
SetParameterValue(request.parameter_id, perfTime,
transfer.Data(), request.size);
request.SendReply(B_OK, &reply, sizeof(reply));
return B_OK;

View File

@ -650,7 +650,7 @@ ContinuousMessageFilter::Filter(BMessage *message, BHandler **target)
"channels\n", fControl->Name(), fParameter.CountChannels());
if (fParameter.SetValue((void *)value, sizeof(value),
system_time()) < B_OK) {
-1) < B_OK) {
ERROR("ContinuousMessageFilter::Filter: Could not set parameter "
"value for %p\n", &fParameter);
return B_DISPATCH_MESSAGE;
@ -760,7 +760,7 @@ DiscreteMessageFilter::Filter(BMessage *message, BHandler **target)
TRACE("DiscreteMessageFilter::Filter: update view %s, value = %ld\n", control->Name(), value);
if (fParameter.SetValue((void *)&value, sizeof(value), system_time()) < B_OK) {
if (fParameter.SetValue((void *)&value, sizeof(value), -1) < B_OK) {
ERROR("DiscreteMessageFilter::Filter: Could not set parameter value for %p\n", &fParameter);
return B_DISPATCH_MESSAGE;
}