1. FastMixerState is a structure,representing a single state of the fast mixer, which limits Fast Mixer containing 8 Fast Tracks at most.
>> 第一个FastTrack[0], 是预留给normal mix thread的 . 从它的BufferProvider 可以看出: “fastTrack->mBufferProvider = new SourceAudioBufferProvider(new MonoPipeReader(monoPipe));”
其中:
a. SourceAudioBufferProvider, inheriting from ExtendedAudioBufferProvider, is assigned to Fast Track as its buffer provider. There is a memory allocation (mAllocated ) to store the data read from the source
if (buffer->frameCount > mSize) {
free(mAllocated);
mAllocated = malloc(buffer->frameCount << mFrameBitShift);
mSize = buffer->frameCount;
} // in SourceAudioBufferProvider::getNextBuffer
b. the mSource of SourceAudioBufferProvider is assigned with MonoPipeReader read ( MonoPipe is its member), which has a ring buffer ( mBuffer(malloc(mMaxFrames * Format_frameSize(format))),mFront is written by consumer, mRear is written by producer),
c. SourceAudioBufferProvider::getNextBufferMonoPipe calls source (MonoPipeReader), MonoPipeReader will read data from ringbufer of MonoPipe, MonoPipe will get the data from the normal mixer buffer in normal threadLoop_wirte, mNormalSink->write(mMixBuffer, count);
d. Each pipe reader contains a data source pipe, when call its read func. to get the data, it finally gets the data from the pipe.
e. The implement of all pops in AuidoFlinger is based on ring buffer.
f.
>> 其它7个fastTracks,
ExtendedAudioBufferProvider *eabp = track; // track is in normal mixthread
VolumeProvider *vp = track;
fastTrack->mBufferProvider = eabp;
>> mFastIndex, this variant used to store the index of AudioTrack in mFastIndex[kMaxFastTracks]
>> when track is created, mFastIndex will be assigned the index in mFastIndex, and bits[mFastIndex]of mTrackMask will be set to 1. On the contrary, when delete the track, mFastIndex will be decreased and bits[mFastIndex]of mTrackMask will be set to 0.
2. FastMixerStateQueue is StateQueue, this queue is maintained in FastMixer , which is defined as: typedefStateQueue<FastMixerState> FastMixerStateQueue;
3. mOutputSink is a important member of FastMixerState, FastMixer finally render mixed pcm data to audio hal through this port.
mOutputSink = new AudioStreamOutSink(output->stream);