[Previous] [Contents] [Next]

Audio Synchronization Mechanisms

Synchronizing audio and video software

There are two standard approaches for software synchronization of audio and video:

  1. Create a variable named BytesWritten to store the number of bytes written to the device. Call snd_pcm_plugin_status() to get the number of bytes in the device from the count value. Subtract count from BytesWritten and convert to milliseconds.
  2. Use the rolling count of bytes written to device (the value of scount in snd_pcm_plugin_status()). Save any offsets needed to adjust time. Add scount to the offset bytes and convert to milliseconds. Remember to watch for underflows, as they reset scount.

Note: These approaches don't include the Society of Motion Picture and Television Engineers (SMPTE) synchronization to external references.

Currently, SMPTE-style synchronization to an external reference source isn't implemented.


In general, synchronizing video to an external time source requires that the video frame clock is slaved to the external time source. This is done by skipping or delaying video frames based on the number of video frames played.

Synchronizing audio to an external source requires that the audio frame clock is slaved to the external time source. This is done by dropping or replicating audio PCM samples.


[Previous] [Contents] [Next]