本文整理汇总了C++中AudioInput::getChannelGroup方法的典型用法代码示例。如果您正苦于以下问题:C++ AudioInput::getChannelGroup方法的具体用法?C++ AudioInput::getChannelGroup怎么用?C++ AudioInput::getChannelGroup使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AudioInput
的用法示例。
在下文中一共展示了AudioInput::getChannelGroup方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: receiveBuffer
void EngineMicrophone::receiveBuffer(AudioInput input, const CSAMPLE* pBuffer,
unsigned int nFrames) {
if (!isTalkover()) {
return;
}
if (input.getType() != AudioPath::MICROPHONE) {
// This is an error!
qWarning() << "EngineMicrophone receieved an AudioInput for a non-Microphone type!";
return;
}
const unsigned int iChannels = input.getChannelGroup().getChannelCount();
// Check that the number of mono frames doesn't exceed MAX_BUFFER_LEN/2
// because thats our conversion buffer size.
if (nFrames > MAX_BUFFER_LEN / iChannels) {
qWarning() << "Dropping microphone samples because the input buffer is too large.";
nFrames = MAX_BUFFER_LEN / iChannels;
}
const CSAMPLE* pWriteBuffer = NULL;
unsigned int samplesToWrite = 0;
if (iChannels == 1) {
// Do mono -> stereo conversion.
for (unsigned int i = 0; i < nFrames; ++i) {
m_pConversionBuffer[i*2 + 0] = pBuffer[i];
m_pConversionBuffer[i*2 + 1] = pBuffer[i];
}
pWriteBuffer = m_pConversionBuffer;
samplesToWrite = nFrames * 2;
} else if (iChannels == 2) {
// Already in stereo. Use pBuffer as-is.
pWriteBuffer = pBuffer;
samplesToWrite = nFrames * iChannels;
} else {
qWarning() << "EngineMicrophone got greater than stereo input. Not currently handled.";
}
if (pWriteBuffer != NULL) {
// TODO(rryan) do we need to verify the input is the one we asked for?
// Oh well.
unsigned int samplesWritten = m_sampleBuffer.write(pWriteBuffer,
samplesToWrite);
if (samplesWritten < samplesToWrite) {
// Buffer overflow. We aren't processing samples fast enough. This
// shouldn't happen since the mic spits out samples just as fast as they
// come in, right?
qWarning() << "ERROR: Buffer overflow in EngineMicrophone. Dropping samples on the floor.";
}
}
}