arduino-audio-tools
Loading...
Searching...
No Matches
Public Member Functions | List of all members
TimeSource Class Reference

Interface for classes that can provide time information - two distinct notions of "now", not interchangeable: millis() is real wall time; playbackTime() is however far actual processing has gotten, which is not the same thing whenever the two can diverge (a consumer blocked/starved, a paused source, ...). A consumer that must stay tied to genuine progress (e.g. PacedVideoOutput scheduling video against actual decoded-audio playback, not merely time passing) should use playbackTime(), not millis(). More...

#include <AudioTypes.h>

Inheritance diagram for TimeSource:
AudioTimeSourceStream

Public Member Functions

virtual uint32_t millis ()
 
virtual uint32_t playbackTime ()
 

Detailed Description

Interface for classes that can provide time information - two distinct notions of "now", not interchangeable: millis() is real wall time; playbackTime() is however far actual processing has gotten, which is not the same thing whenever the two can diverge (a consumer blocked/starved, a paused source, ...). A consumer that must stay tied to genuine progress (e.g. PacedVideoOutput scheduling video against actual decoded-audio playback, not merely time passing) should use playbackTime(), not millis().

Note
This is a pure virtual interface class and cannot be instantiated directly.
Author
Phil Schatzmann

Member Function Documentation

◆ millis()

virtual uint32_t millis ( )
inlinevirtual

Wall-clock elapsed time (ms) - real time passing, regardless of whatever this TimeSource actually tracks. The default implementation just forwards to Arduino's own millis(); override only if this TimeSource needs a different wall-clock source - most subclasses should leave this alone and override playbackTime() instead.

◆ playbackTime()

virtual uint32_t playbackTime ( )
inlinevirtual

Elapsed time (ms) derived purely from what this TimeSource has actually processed so far - never extrapolated from, or otherwise dependent on, millis()/wall-clock time (see millis()'s own comment). Stalls exactly when processing stalls instead of continuing to advance the way millis() does. The default implementation just forwards to millis() (i.e. "nothing special is tracked, wall time is the best available approximation") - override this in any TimeSource that actually tracks processed data instead (see AudioTimeSourceStream, AudioTools/CoreAudio/AudioIO.h).

Reimplemented in AudioTimeSourceStream.


The documentation for this class was generated from the following file: