|
Sound Byte Libs 0.5.1-340-gab5b79a
C++ firmware library for audio applications on 32-bit ARM Cortex-M processors
|
The audio driver's frame count and the frame stamp. More...
The audio driver's frame count and the frame stamp.
FrameCount counts the stereo frames the audio driver has delivered to the codec since boot. It is driver state, not a clock: control time is control/clock.hpp over the system timer. One writer, the audio driver, which stamps before each block's callback and advances after it; any context may read. Readers take unsigned deltas, correct across the wrap every 2^32 frames (about 24.8 h at 48 kHz).
The frame stamp pairs the count with the system timer: at each driver period, before the app callback, the driver records {frames, ticks}, frames being the first frame of the block the callback computes and ticks the system timer's count then. It is written in the audio ISR and read in the audio callback - one context, so the two words cannot tear. A reader in another context would need a sequence counter, which the stamp does not have.
The counter is a relaxed atomic: race-free between the audio thread and the control thread on the workbench, plain LDR/STR on Cortex-M7. It publishes no other data, so no ordering is needed.
Definition in file frame_count.hpp.
#include <atomic>#include <cstdint>Go to the source code of this file.
Classes | |
| struct | sbl::hal::audio::FrameStamp |
| class | sbl::hal::audio::FrameCount |
Namespaces | |
| namespace | sbl |
| Root namespace for all Sound Byte Libs code. | |
| namespace | sbl::hal |
| Hardware abstraction: peripheral handles, driver contracts. | |
| namespace | sbl::hal::audio |
| Audio streams and the sample clock. | |