Skip to content

Commit

Permalink
BControllable: Fix real_time and perf_time mismatch
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
Numerio committed Apr 7, 2016
1 parent 15b4841 commit f441a1e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
12 changes: 11 additions & 1 deletion src/kits/media/Controllable.cpp
Expand Up @@ -39,6 +39,7 @@
#include <OS.h>
#include <ParameterWeb.h>
#include <Roster.h>
#include <TimeSource.h>

#include <debug.h>
#include <DataExchange.h>
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/kits/media/DefaultMediaTheme.cpp
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit f441a1e

Please sign in to comment.