FastTack
- FastTack and Normal Track
- Mixer Threads
- Fast mixer
- Normal mixer
FastTack and Normal Track
Android 4.1 開始 Audio的變化之一就是有了audio output path:lower latency
所謂的low latency 即 對應native framework層的fast track 和fastmixer
也是application framework層對應的STATIC_MODE
FAST TACK 的創建
通過flag的設置創建,在AudioTrack 的構造函數或者AudioTrack::set()中將參數audio_output_flags_t設置為 AUDIO_OUTPUT_FLAG_FAST
目前使用fastrack的例子如:
AudioTrack會去檢驗AUDIO_OUTPUT_FLAG_FAST的設置是否合理,可能會以客戶端的層次上否定要求的fasttrack方式;
同樣AudioFlinger也會去進一步檢驗,并且可能在audio服務端的層次上否定在AudioTrack中的設置,然后通知客戶端是否fastrack的要求被接受,客戶端通過共享內存的方式獲取fastrack flags來加以控制
normal track 是相對于fasttrack來說的,除了fasttrack其他成為normal track
Mixer Threads
AudioFlinger創建Mixer Threads的時候就會決定是否也創建一個快速混音線程fast mixer thread,Normal mixer 與 fast mixer 跟一組tracks有關.
總是會存在一個Normal mixer thread,而Fast mixer thread如果存在的話,一定受Normal mixer thread控制并且從屬于它。
Fast mixer
特點:
- Mixing of the normal mixer’s sub-mix and up to 7 client fast tracks
- Per track attenuation
周期性
Fast mixer以推薦的2至3毫秒的時間周期性運行,如果因為調度穩定性有需要可以稍微增加到5毫秒的周期。選定這樣的周期總延時大約10毫秒。更小的周期也可以,但是會增加功耗和出現故障的機會。更大的周期可以達到20毫秒,但是會導致總延時的退化,因此應避免。
Scheduling
Fast mixer遵從fifo優先級運行。它只需要很少的CPU時間,但運行頻繁,具有低調度jitter。jitter表示周期時間的變化:實際循環時間與預期周期時間之間的差異。不能運行太早也不能太晚。
Blocking
除了在hal層write()數據,理想狀態下Fast mixer從來不會阻塞,否則就被認為是bug。Relationship to other components
Fast mixer 與客戶端很少有直接的交互. 特別是它沒有binder級別的操作,但是卻可以訪問 客戶端的共享內存控制塊.The fast mixer receives commands from the normal mixer via a state queue.Other than pulling track data, interaction with clients is via the normal mixer.The fast mixer's primary sink is the audio HAL.Normal mixer
特征
Up to 32 tracks
Per track attenuation(衰減)
Per track sample rate conversion(轉換)
Effects processing
周期(Period)
The period is computed to be the first integral multiple(integral multiple:整倍數) of the fast mixer period that is >= 20 ms.Scheduling
The normal mixer runs at elevated SCHED_OTHER priority(優先級).
Blocking
The normal mixer is permitted to block, and often does so at various mutexes as well as at a blocking pipe to write its sub-mix.
Relationship to other components
The normal mixer interacts extensively with the outside world, including binder threads, audio policy manager, fast mixer thread, and client tracks.
The normal mixer’s sink is a blocking pipe to the fast mixer’s track 0.
Flags
AUDIO_OUTPUT_FLAG_FAST bit is a hint. There’s no guarantee the request will be fulfilled.
AUDIO_OUTPUT_FLAG_FAST is a client-level concept. It does not appear in server.
TRACK_FAST is a client -> server concept.
總結
- 上一篇: 1072: 花生采摘
- 下一篇: 模板和代码生成器