tree: 2ebd67d865240a55de1470749df9e21bb8ccc981 [path history] [tgz]
  1. BUILD.gn
  2. main.cc
  3. README.md
  4. simple_sine_sync.cc
  5. simple_sine_sync.h
examples/media/simple_sine_sync/README.md

Simple Sine 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

  simple_sine_sync [--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 audio renderer 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 renderer needs more data, it will continue sending packets until there is at least this much audio data queued at the renderer. 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