[haiku-commits] Re: haiku: hrev49508 - src/kits/media

  • From: Dario Casalinuovo <b.vitruvio@xxxxxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Wed, 19 Aug 2015 15:58:01 +0200

Hi Ingo,


No, that is not correct. Since HandleEvent() is called immediately, the
callee can still get the dequeue time (respectively just a few cycles
later) and compute the lateness value you're computing.


That makes sense, but still looks strange that BeOS didn't use it. I mean
that there may be still a better solution than that. But at this point no
reason to go forward for me, actually BMediaEventLooper doesn't fit my
needs and i'm maybe trying to achieve more than what it can. So since the
majority is of this opinion i'll do it the way we discussed.


From what i can see, the Be's released nodes expect that lateness is
the dequeue lateness...


If you have concrete pointers, feel free to post them. However...


The first example that comes to my mind is the calculus done in the
LoggingConsumer. It's ignoring lateness but do the same calculus i'm doing
in my implementation of BMediaEventLooper to check if it's late. The same
formula is showed more than one time in the bebook.

It's right, but still i can't see why we should have a scheduling
latency if we don't use it in a meaningful way.


The thing is, the scheduling latency is not particularly useful, save for
guessing some initial total node latency. Afterward only the total node
latency is relevant. You can't really separate its components -- scheduling
and event latency -- anyway. E.g. heavy system load may cause the thread to
wake up slower, be preempted more often, and generally do computations more
slowly due to processor cache effects. It is a fairly useless exercise to
try and separate the two conceptual latency components.


Well at this point i would change the lateness parameter name to some more
clear name, such as enqueueLatency.


It also doesn't matter which component you increase, since the net effect
will be exactly the same (handling an event will start that much earlier).


Let consider for simplicity that all nodes will have the same jitter in
such situations, such as X, then i'm observing that instead to increase all
nodes latency of an X value, the nodes can recover better if they use some
fraction of this, taking into account also other things.


We can increase the scheduling latency, still using the enqueue_time,
but do more calculus on the late value so that we can recognize when
it's not an upstream fault.


Whatever you do, the point still stands: it makes most sense to pass the
arrival lateness to HandleEvent(). You certainly can do some additional
computations and increase the scheduling latency. However, that should also
be completely superfluous and probably even detrimental. If the arrival
lateness is passed to HandleEvent() the implementation is able to (and
should) determine whether it has to notify the producer that the buffer was
late and/or adjust its own latency when necessary (when handling the buffer
takes longer than expected). In the latter case adjusting the scheduling
latency automatically in BMediaEventLooper may cause the total node latency
to be adjusted twice as much in the end, unless you additional adjust the
lateness value to compensate.


There's still a bit of playground in the whole chain latency.


No, it won't. As explained above, there is only one latency that matters:
The node's total latency. It is completely irrelevant whether the
scheduling or the event latency is increased, as only their sum is used
anyway (determining the time when to wake up for processing an event).

Instead using the proposed lateness meaning, we will just workaround the
problem without changing anything in the BMediaEventLooper flexibility
improvements we can have.


Using a useful lateness semantics will 1. fix the actual problem and 2. be
a fairly simple change. It will not require introducing additional API. The
"flexibility improvements" you mention are very vague. At least the
automatic scheduling adjustment part you mentioned won't improve anything.
It will just make things more complicated, since you'll have to
additionally manipulate the lateness value to avoid double adjustments of
the total node latency.


Well, not really. If we adjust the scheduling latency using the enqueue
lateness, then we can subtract this value and try to report only the part
needed for the late notice.


Sorry, this is all so vague that it's hard to say anything about it. You
imply that we deal with complex graphs.


Isn't the actual media_kit something supporting complex graphs? It can
theoretically have any number of nodes with any kind of N:N connections.
The fact that Haiku doesn't have applications using it extensively doesn't
mean that we shouldn't go in the direction that almost all general purpose
realtime processing systems are going. We have to attract developers,
otherwise what's the point of Haiku?


However, the most complex thing I see is the audio mixer node, which has
multiple inputs and multiple outputs. Pretty much everything else is
basically just simple chains of nodes. I don't see what graph algorithms
you intend to use and for what (concrete) purpose.


Since the media_kit isn't so smart at such things compared to jack or
AudioUnits, i doubt we'll see any. Just remember how many companies such as
steinberg were interested in using BeOS to do DAW processing, but resigned.
Isn't it a reason to leave the media_kit as something for Desktop purposes
(MediaPlayer etc.) but provide an improved kit for realtime?

--
Saluti,
Dario

« Nullius addictus iurare in verba magistri, quo me cumque rapit tempestas,
deferor hospes. »

Other related posts: