// Ensure that buffer depth covers at least audio hardware latency uint32_t minBufCount = afLatency / ((1000 * afFrameCount) / afSampleRate); if (minBufCount < 2) minBufCount = 2; *frameCount = (sampleRate == 0) ? afFrameCount * minBufCount : afFrameCount * minBufCount * sampleRate / afSampleRate; return NO_ERROR;
Latency 是問hardware.,,經由OutputDescriptor 傳回 (include/media/AudioSystem.h)
class OutputDescriptor { public: OutputDescriptor() : samplingRate(0), format(0), channels(0), frameCount(0), latency(0) {} uint32_t samplingRate; int32_t format; int32_t channels; size_t frameCount; uint32_t latency; };或是 IAudioFlinger.
這個latency 直,是由 alsa 的 bufferSize 算出來的。
在 hardware/alsa_sound/alsa_default.cpp..
static alsa_handle_t _defaultsOut = { module : 0, devices : AudioSystem::DEVICE_OUT_ALL, curDev : 0, curMode : 0, handle : 0, format : SND_PCM_FORMAT_S16_LE, // AudioSystem::PCM_16_BIT channels : 2, sampleRate : DEFAULT_SAMPLE_RATE, latency : 40000, // Desired Delay in usec bufferSize : 8192, // Desired Number of samples mmap : 0, modPrivate : 0, };這裡的bufferSize, 變更的話, latency 值就會改變。
沒有留言:
張貼留言