MRM TimeDelegate Class


The TimeDelegate class provides access to current device time, clock characteristics, and playback offset.

TimeDelegate Class Declaration

This is a sample declaration of the TimeDelegate class:

class TimeDelegate {
public:
    virtual int getLocalTimeNs(int64_t *localTime) = 0;
    virtual double getNominalDriftPpm() = 0;
    virtual double getDriftTolerancePpm() = 0;
    virtual double getAudioDriftPpm() = 0;
    virtual int getPlayOffsetNs(int64_t *offset) = 0;
}

getLocalTimeNs()

Implement this function to return the current local time (this is the time used PlaybackDelegate::write()).

Return 0 on success and non-0 otherwise.

The total time to call this function and return a valid result must be less than 3 microseconds TP99. There may be occasions when the implementation is interrupted by the scheduler, and the time to return a result is greater than 3 microseconds. However, more than 99% of the time, the result must be returned within 3 microseconds.

The time returned must be in nanoseconds, and the clock must be constant frequency (not affected by power state transitions), monotonic, and free-running (never corrected by processes like NTP).

virtual int getLocalTimeNs(int64_t *localTime) = 0;
Parameter Description
int64_t *localTime Local time.

getNominalDriftPpm()

Implement this function to return the nominal value of local clock drift in parts per million (ppm) with a precision of 0.001 ppm.

A positive drift value means the local clock is slower than the reference clock, and a negative value means the local clock is faster than the reference clock.

getNominalDriftPpm() and getDriftTolerancePpm() are called when the WHA class starts time synchronizations, which usually happens when WHA is started.

This value is produced as part of the WHA prequalification tests.

virtual double getNominalDriftPpm() = 0;

getDriftTolerancePpm()

Implement this function to return drift tolerance in parts per million (ppm) with a precision of 0.001 ppm.

This value is produced as part of the WHA prequalification tests.

virtual double getDriftTolerancePpm() = 0;

getAudioDriftPpm()

Implement this function to return the drift value between the clock used by getLocalTime() and the audio clock. The value should be in parts per million (ppm) with a precision of 0.001 ppm.

A positive drift value means the audio clock is slower than the local clock, and a negative value means the audio clock is faster than the local clock.

The function is called when audio playback starts.

This value is produced as part of the WHA prequalification tests.

virtual double getAudioDriftPpm() = 0;

getPlayOffsetNs()

Implement this function to return a time offset in nanoseconds.

This value is used for fine-tuning audio positioning with respect to the line out of an Echo Dot (2nd Generation). A positive value moves the audio into the future, and a negative value moves the audio into the past by offset nanoseconds.

This value is produced as part of the WHA prequalification tests.

virtual int getPlayOffsetNs(int64_t *offset) = 0;
Parameter Description
int64_t *offset Offset

Was this page helpful?

Last updated: Nov 27, 2023