写这个的目的主要是自己做个总结和积累,看别人的比较容易忘记。
开始会比较乱,慢慢再整理。
1.audio 的数据流向
android 的音频数据都必须用audioTrack才能往下写,所以每一次播放声音都要创建audioTrack, AudioTrack::set()函数是AudioTrack 创建的时候真正处理的函数。
status_t AudioTrack::set(
audio_stream_type_t streamType,
uint32_t sampleRate,
audio_format_t format,
audio_channel_mask_t channelMask,
int frameCountInt,
audio_output_flags_t flags,
callback_t cbf,
void* user,
int notificationFrames,
const sp<IMemory>& sharedBuffer,
bool threadCanCallJava,
int sessionId,
transfer_type transferType,
const audio_offload_info_t *offloadInfo)
{
// 数据传输类型
switch (transferType) {
case TRANSFER_DEFAULT:
if (sharedBuffer != 0) {
transferType = TRANSFER_SHARED;
} else if (cbf == NULL