tree: ed2ff8b67b8bd5e8b9aa34d1de7d24328b15c3c2 [path history] [tgz]
  1. meta/
  2. BUILD.gn
  3. main.cc
  4. README.md
  5. sync_sine.cc
  6. sync_sine.h
examples/media/audio/sync_sine/README.md

Simple Sync Example App

This example is similar to the Simple Sine example but uses synchronous interfaces to show how to perform audio playback without relying on a particular message loop interface. It plays the same audio as the simple sine example and has the same setup scheme, but controls playback in a slightly different way.

USAGE

  sync_sine [--wake=nn] [--sleep=nn] [--float] [--v|--verbose]

The --wake flag specifies this application's low water mark, expressed in milliseconds. When the amount of audio queued at the AudioRendererSync falls below this amount, the application will be awakened to provide more audio. If not provided, a default value of 30 milliseconds is used.

The --sleep flag specifies this application's high water mark, expressed in milliseconds. When the application starts up, or when it is awakened because the AudioRendererSync needs more data, it will continue sending packets until there is at least this much audio data queued at the AudioRendererSync. If not provided, a default value of 50 milliseconds is used. This value cannot be less than the --wake value (whether specified or default, for both values). If this would be the case, then this value is set to the --wake value.

The --float flag specifies that the audio data generated by the app and passed to the system will be in 32-bit floating-point format, where 1.0 and -1.0 represent the maximum and minimum full-scale, respectively.

The --verbose flag enables additional printf logging for debugging purposes.

Warm-up

The example first computes a presentation time for the first packet based on an estimate of the warm-up time of the system and populates a few frames of data.

Playback

Once a few packets are prepared, the example initiates playback (by configuring the timeline transform) and begins its primary playback loop. The playback loop's job is to maintain a minimum buffer of pending packets in flight until playback is complete. This loop is composed of 3 steps:

1.) Look at the current time and compute how many packets need to be supplied in order to restore the desired buffer

2.) Generate and supply this many packets

3.) Sleep until it is time to generate more packets