Bug 1404997 - P7. Simplify played time calculations. r=pehrsons

Now that the graph rate match the one out of NetEQ, we can remove an unecessary conversion.

Additionally, move a member from the base case to the only one where it's used.

MozReview-Commit-ID: II5mdcl0vhK

--HG--
extra : rebase_source : 1d9edfc2803c3fadde7505b4d84293640e4311e0
This commit is contained in:
Jean-Yves Avenard 2017-12-08 20:58:09 +01:00
Родитель 2ecd33016c
Коммит b8ec246a1f
2 изменённых файлов: 13 добавлений и 9 удалений

Просмотреть файл

@ -186,12 +186,13 @@ MediaStreamGraphImpl::ExtractPendingInput(SourceMediaStream* aStream,
// Compute how much stream time we'll need assuming we don't block
// the stream at all.
StreamTime t = aStream->GraphTimeToStreamTime(aDesiredUpToTime);
StreamTime current = aStream->mTracks.GetEnd();
LOG(LogLevel::Verbose,
("Calling NotifyPull aStream=%p t=%f current end=%f",
aStream,
MediaTimeToSeconds(t),
MediaTimeToSeconds(aStream->mTracks.GetEnd())));
if (t > aStream->mTracks.GetEnd()) {
MediaTimeToSeconds(current)));
if (t > current) {
*aEnsureNextIteration = true;
#ifdef DEBUG
if (aStream->mListeners.Length() == 0) {
@ -200,7 +201,7 @@ MediaStreamGraphImpl::ExtractPendingInput(SourceMediaStream* aStream,
("No listeners in NotifyPull aStream=%p desired=%f current end=%f",
aStream,
MediaTimeToSeconds(t),
MediaTimeToSeconds(aStream->mTracks.GetEnd())));
MediaTimeToSeconds(current)));
aStream->DumpTrackInfo();
}
#endif

Просмотреть файл

@ -2075,7 +2075,6 @@ public:
explicit GenericReceiveListener(dom::MediaStreamTrack* track)
: track_(track)
, played_ticks_(0)
, last_log_(0)
, principal_handle_(PRINCIPAL_HANDLE_NONE)
, listening_(false)
, maybe_track_needs_unmute_(true)
@ -2184,7 +2183,6 @@ public:
protected:
RefPtr<dom::MediaStreamTrack> track_;
TrackTicks played_ticks_;
TrackTicks last_log_; // played_ticks_ when we last logged
PrincipalHandle principal_handle_;
bool listening_;
Atomic<bool> maybe_track_needs_unmute_;
@ -2209,6 +2207,7 @@ public:
const RefPtr<MediaSessionConduit>& conduit)
: GenericReceiveListener(track)
, conduit_(conduit)
, last_log_(0)
{
}
@ -2239,11 +2238,13 @@ public:
}
TrackRate rate = graph->GraphRate();
uint32_t samples_per_10ms = rate/100;
uint32_t samples_per_10ms = rate / 100;
// Determine how many frames we need.
// As we get frames from conduit_ at the same rate as the graph's rate,
// the number of frames needed straightfully determined.
TrackTicks framesNeeded = desired_time - played_ticks_;
// This comparison is done in total time to avoid accumulated roundoff errors.
while (source->TicksToTimeRoundDown(rate,
played_ticks_) < desired_time) {
while (framesNeeded >= 0) {
int16_t scratch_buffer[AUDIO_SAMPLE_BUFFER_MAX_BYTES / sizeof(int16_t)];
int samples_length;
@ -2307,6 +2308,7 @@ public:
// Handle track not actually added yet or removed/finished
if (source->AppendToTrack(track_->GetInputTrackId(), &segment)) {
framesNeeded -= frames;
played_ticks_ += frames;
if (MOZ_LOG_TEST(AudioLogModule(), LogLevel::Debug)) {
if (played_ticks_ > last_log_ + rate) { // ~ 1 second
@ -2332,6 +2334,7 @@ public:
private:
RefPtr<MediaSessionConduit> conduit_;
TrackTicks last_log_; // played_ticks_ when we last logged
};
MediaPipelineReceiveAudio::MediaPipelineReceiveAudio(