positionUs property

int? get positionUs

True playback position, from what the audio device has actually consumed.

Null until audio starts flowing, which is what the player wants: an unanchored clock means "nothing is due yet" rather than "we are at zero".

Implementation

int? get positionUs {
  if (_closed || _sampleRate <= 0) return null;
  final consumed = _sink.ring.framesConsumed - _baselineFrames;
  if (consumed <= 0 && _baselinePtsUs == 0) return null;
  return _baselinePtsUs + (consumed * 1000000) ~/ _sampleRate;
}