next event calculation properly based on frames played in performace time now
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@3401 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
f180ef79b2
commit
11b92ae72b
@ -1242,7 +1242,7 @@ AudioMixer::HandleEvent( const media_timed_event *event, bigtime_t lateness, boo
|
||||
// if this is the first buffer, mark with the start time
|
||||
// we need this to calculate the other buffer times
|
||||
if (fStartTime == 0) {
|
||||
fStartTime = TimeSource()->RealTimeFor(event->event_time, 0);
|
||||
fStartTime = event->event_time;
|
||||
}
|
||||
|
||||
// count frames that have been played
|
||||
@ -1252,7 +1252,7 @@ AudioMixer::HandleEvent( const media_timed_event *event, bigtime_t lateness, boo
|
||||
fFramesSent += framesperbuffer;
|
||||
|
||||
// calculate the start time for the next event and add the event
|
||||
bigtime_t nextevent = TimeSource()->PerformanceTimeFor(bigtime_t(fStartTime + double(fFramesSent / fOutput.format.u.raw_audio.frame_rate) * 1000000.0));
|
||||
bigtime_t nextevent = bigtime_t(fStartTime + double(fFramesSent / fOutput.format.u.raw_audio.frame_rate) * 1000000.0);
|
||||
media_timed_event nextBufferEvent(nextevent, SEND_NEW_BUFFER_EVENT);
|
||||
EventQueue()->AddEvent(nextBufferEvent);
|
||||
break;
|
||||
|
@ -608,7 +608,7 @@ _SoundPlayNode::SendNewBuffer(const media_timed_event *event, bigtime_t lateness
|
||||
|
||||
// The buffer is on its way; now schedule the next one to go
|
||||
// nextEvent is the time at which the buffer should arrive at it's destination
|
||||
bigtime_t nextEvent = TimeSource()->PerformanceTimeFor(mStartTime + bigtime_t((1000000LL * mFramesSent) / mOutput.format.u.raw_audio.frame_rate));
|
||||
bigtime_t nextEvent = mStartTime + bigtime_t((1000000LL * mFramesSent) / mOutput.format.u.raw_audio.frame_rate);
|
||||
media_timed_event nextBufferEvent(nextEvent, SEND_NEW_BUFFER_EVENT);
|
||||
EventQueue()->AddEvent(nextBufferEvent);
|
||||
|
||||
@ -650,7 +650,7 @@ _SoundPlayNode::HandleStart(
|
||||
// and fire off the first "produce a buffer" event.
|
||||
|
||||
mFramesSent = 0;
|
||||
mStartTime = TimeSource()->RealTimeFor(event->event_time, 0);
|
||||
mStartTime = event->event_time;
|
||||
media_timed_event firstBufferEvent(event->event_time, SEND_NEW_BUFFER_EVENT);
|
||||
|
||||
// Alternatively, we could call HandleEvent() directly with this event, to avoid a trip through
|
||||
|
Loading…
Reference in New Issue
Block a user