[haiku-commits] haiku: hrev50075 - in src: add-ons/media/media-add-ons/multi_audio kits/media

  • From: b.vitruvio@xxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sun, 7 Feb 2016 23:24:44 +0100 (CET)

hrev50075 adds 2 changesets to branch 'master'
old head: 2e3e1a5902f4fd9824c90dff7fc45c638b67c834
new head: 801b3e3bf487edd9de0c68bdf44f749370849e38
overview: 
http://cgit.haiku-os.org/haiku/log/?qt=range&q=801b3e3bf487+%5E2e3e1a5902f4

----------------------------------------------------------------------------

730d0700f5e7: MultiAudioNode: Remove custom lateness code

801b3e3bf487: MediaEventLooper: Add more safeness on exit
  
  * The WaitForMessage is moved at the end of the loop, and
  the check for quitting the loop is moved as it's condition,
  this makes us to be sure that once a Quit() request is performed
  we will not handle events anymore.
  * Other minor style and initialization fixes.

                                [ Dario Casalinuovo <b.vitruvio@xxxxxxxxx> ]

----------------------------------------------------------------------------

2 files changed, 10 insertions(+), 21 deletions(-)
.../media-add-ons/multi_audio/MultiAudioNode.cpp     | 15 ++++-----------
src/kits/media/MediaEventLooper.cpp                  | 16 ++++++----------

############################################################################

Commit:      730d0700f5e76a35cdd22e27c30bfc9a2c0421bd
URL:         http://cgit.haiku-os.org/haiku/commit/?id=730d0700f5e7
Author:      Dario Casalinuovo <b.vitruvio@xxxxxxxxx>
Date:        Tue Feb  2 22:50:39 2016 UTC

MultiAudioNode: Remove custom lateness code

----------------------------------------------------------------------------

diff --git a/src/add-ons/media/media-add-ons/multi_audio/MultiAudioNode.cpp 
b/src/add-ons/media/media-add-ons/multi_audio/MultiAudioNode.cpp
index 69b6572..fc22874 100644
--- a/src/add-ons/media/media-add-ons/multi_audio/MultiAudioNode.cpp
+++ b/src/add-ons/media/media-add-ons/multi_audio/MultiAudioNode.cpp
@@ -1163,20 +1163,13 @@ MultiAudioNode::_HandleBuffer(const media_timed_event* 
event,
                return B_MEDIA_BAD_DESTINATION;
        }
 
-       bigtime_t now = TimeSource()->Now();
-       bigtime_t performanceTime = buffer->Header()->start_time;
-
-       // the how_early calculate here doesn't include scheduling latency 
because
-       // we've already been scheduled to handle the buffer
-       bigtime_t howEarly = performanceTime - EventLatency() - now;
-
        // if the buffer is late, we ignore it and report the fact to the 
producer
        // who sent it to us
-       if (RunMode() != B_OFFLINE && RunMode() != B_RECORDING && howEarly < 
0LL) {
+       if (RunMode() != B_OFFLINE && RunMode() != B_RECORDING && lateness > 0) 
{
                // lateness doesn't matter in offline mode or in recording mode
                //mLateBuffers++;
-               NotifyLateProducer(channel->fInput.source, -howEarly, 
performanceTime);
-               fprintf(stderr,"        <- LATE BUFFER : %" B_PRIdBIGTIME "\n", 
howEarly);
+               NotifyLateProducer(channel->fInput.source, lateness, 
event->event_time);
+               fprintf(stderr,"        <- LATE BUFFER : %" B_PRIdBIGTIME "\n", 
lateness);
                buffer->Recycle();
        } else {
                //WriteBuffer(buffer, *channel);
@@ -1185,7 +1178,7 @@ MultiAudioNode::_HandleBuffer(const media_timed_event* 
event,
                if (channel->fBuffer != NULL) {
                        PRINT(("MultiAudioNode::HandleBuffer snoozing recycling 
channelId : %"
                                        B_PRIi32 ", how_early:%" B_PRIdBIGTIME 
"\n",
-                               channel->fChannelId, howEarly));
+                               channel->fChannelId, lateness));
                        //channel->fBuffer->Recycle();
                        snooze(100);
                        if (channel->fBuffer != NULL)

############################################################################

Revision:    hrev50075
Commit:      801b3e3bf487edd9de0c68bdf44f749370849e38
URL:         http://cgit.haiku-os.org/haiku/commit/?id=801b3e3bf487
Author:      Dario Casalinuovo <b.vitruvio@xxxxxxxxx>
Date:        Sun Feb  7 22:13:22 2016 UTC

MediaEventLooper: Add more safeness on exit

* The WaitForMessage is moved at the end of the loop, and
the check for quitting the loop is moved as it's condition,
this makes us to be sure that once a Quit() request is performed
we will not handle events anymore.
* Other minor style and initialization fixes.

----------------------------------------------------------------------------

diff --git a/src/kits/media/MediaEventLooper.cpp 
b/src/kits/media/MediaEventLooper.cpp
index 3eae844..0af1a72 100644
--- a/src/kits/media/MediaEventLooper.cpp
+++ b/src/kits/media/MediaEventLooper.cpp
@@ -213,7 +213,7 @@ BMediaEventLooper::ControlLoop()
 {
        CALLED();
 
-       status_t err;
+       status_t err = B_OK;
        bigtime_t waitUntil = B_INFINITE_TIMEOUT;
        bool hasRealtime = false;
        bool hasEvent = false;
@@ -224,11 +224,7 @@ BMediaEventLooper::ControlLoop()
        // we need to handle the next event
 
        fSchedulingLatency = estimate_max_scheduling_latency(fControlThread);
-       while (true) {
-               if (RunState() == B_QUITTING)
-                       return;
-
-               err = WaitForMessage(waitUntil);
+       while (RunState() != B_QUITTING) {
                if (err == B_TIMED_OUT
                                || err == B_WOULD_BLOCK) {
                        // NOTE: The reference for doing the lateness calculus 
this way can
@@ -255,7 +251,8 @@ BMediaEventLooper::ControlLoop()
                                if (waitUntil > 0) {
                                        lateness = waitUntil - 
TimeSource()->RealTime();
                                        if (lateness > 0) {
-                                               bigtime_t enqueueLatency = 
event.enqueue_time - waitUntil;
+                                               bigtime_t enqueueLatency
+                                                       = event.enqueue_time - 
waitUntil;
                                                if (enqueueLatency > 0)
                                                        lateness += 
enqueueLatency;
                                        }
@@ -285,10 +282,8 @@ BMediaEventLooper::ControlLoop()
                                waitUntil = 0;
                                hasBooted = true;
                        }
-               } else if (!hasRealtime) {
+               } else if (!hasRealtime)
                        waitUntil = B_INFINITE_TIMEOUT;
-                       continue;
-               }
 
                if (hasRealtime) {
                        bigtime_t realtimeWait = fRealTimeQueue.FirstEventTime()
@@ -300,6 +295,7 @@ BMediaEventLooper::ControlLoop()
                        } else
                                hasRealtime = false;
                }
+               err = WaitForMessage(waitUntil);
        }
 }
 


Other related posts:

  • » [haiku-commits] haiku: hrev50075 - in src: add-ons/media/media-add-ons/multi_audio kits/media - b . vitruvio