AudioQueue几个重要参数
AudioQueueRef inputQueue;//队列 AudioQueueBufferRef inputBuffers[3];//缓冲区 可以定义宏容易修改,一般为3个,设置多个可以让语音播放不卡 AudioStreamBasicDescription audioDescription;//音频采集参数设置
///设置音频参数 audioDescription.mSampleRate = 8000; //采样率 audioDescription.mFormatID = kAudioFormatLinearPCM; audioDescription.mFormatFlags = kLinearPCMFormatFlagIsSignedInteger | kAudioFormatFlagIsPacked; audioDescription.mChannelsPerFrame = 1; ///单声道 audioDescription.mFramesPerPacket = 1; //每一个packet一侦数据 audioDescription.mBitsPerChannel = 16; //每个采样点16bit量化 audioDescription.mBytesPerFrame = (audioDescription.mBitsPerChannel / 8) * audioDescription.mChannelsPerFrame; audioDescription.mBytesPerPacket = audioDescription.mBytesPerFrame; AudioQueueNewOutput(&audioDescription, AudioPlayerAQInputCallback, (__bridge void*)self, nil, nil, 0, &audioQueue); //使用player的内部线程播放
AudioQueueAllocateBuffer(audioQueue, MIN_SIZE_FRAME, &audioQueueBuffers[i]);//初始化音频缓冲区
AudioQueueStop(audioQueue, true);//停止队列 AudioQueueReset(audioQueue);//重置队列 AudioQueueDispose(_inputQueue, true);//销毁队列
时间: 2024-12-20 16:10:16