Digital Signal Processing Reference
In-Depth Information
Fig. 5. ALSA Basic Architecture
(1) Open audio device: snd_pcm_open();
(2) Set hardware parameters [11]: snd_pcm_hw_params_set() assigning value to
parameter variables and snd_pcm_hw_params() passing parameters to audio device;
(3) Read PCM data: snd_pcm_readi();
(4) Close audio device: snd_pcm_close().
In this way, an audio capturing program with recording function is complete. But
actually step (4) won't be executed until audio thread stops running.
3.1.2 Audio Data Encoding
Audio data encoding can be realized mainly by open source software FAAC. But A5s
SDK provides an optimized AAC API library called libaacenc [12] with main API
functions as follows to compress audio PCM data.
(1)aacenc_setup(&au_aacenc_config): assign the AAC encode control structures
“au_aacenc_config” to the internal operation variables to set the correct configura-
tions.
(2)aacenc_open(&au_aacenc_config): allocate the related memories for the AAC
before starting the AAC encode.
(3)aacenc_encode(&au_aacenc_config): start the AAC encoding and generate one
frame of audio data after setting AAC encode control structure and allocating
memories.
3.1.3 Audio Module Design
As illustrated in Fig. 6, audio thread AudioDaemon extracts PCM data captured by
audio device from FIFO, calls AAC API functions to encode audio data block by
block, adds timestamps to the encoded data and finally dispatches it to AudioBuffer.
Typically, aacenc_encode function once called only encodes 1024 PCM samples.
Common parameters in ALSA configuration and AAC configuration such as sample
rate, channels and sample size must be set identically.
Search WWH ::




Custom Search