IMemory接口
在createTrack的过程中,AudioFlinger会根据传入的frameCount参数,申请一块内存,AudioTrack可以通过IAudioTrack接口的getCblk()函数获得指向该内存块的IMemory接口,然后AudioTrack通过该IMemory接口的pointer()函数获得指向该内存块的指针,这块内存的开始部分就是audio_track_cblk_t结构,紧接着是大小为frameSize的FIFO内存。
IMemory->pointer() ---->|_______________________________________________________
|__audio_track_cblk_t__|_______buffer of FIFO(size==frameCount)____|
看看AudioTrack的createTrack()的代码就明白了:
- sp track = audioFlinger->createTrack(getpid(),
- streamType,
- sampleRate,
- format,
- channelCount,
- frameCount,
- ((uint16_t)flags) << 16,
- sharedBuffer,
- output,
- &status);
-
- sp cblk = track->getCblk();
- mAudioTrack.clear();
- mAudioTrack = track;
- mCblkMemory.clear();
- mCblkMemory = cblk;
-
- mCblk = static_cast(cblk->pointer());
-
- mCblk->out = 1;
-
- mFrameCount = mCblk->frameCount;
- if (sharedBuffer == 0) {
-
- mCblk->buffers = (char*)mCblk + sizeof(audio_track_cblk_t);
- } else {
- ..........
-
阅读(2674) | 评论(0) | 转发(1) |