本文整理汇总了C++中Audio::audioCallback方法的典型用法代码示例。如果您正苦于以下问题:C++ Audio::audioCallback方法的具体用法?C++ Audio::audioCallback怎么用?C++ Audio::audioCallback使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Audio
的用法示例。
在下文中一共展示了Audio::audioCallback方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: auAudioOutputCallback
void auAudioOutputCallback(void *SELF, AudioQueueRef queue, AudioQueueBufferRef buffer)
{
Audio* self = (Audio*) SELF;
int resultFrames = self->audioCallback(SELF, (auSample_t*)buffer->mAudioData, (buffer->mAudioDataBytesCapacity / self->dataFormat.mBytesPerFrame), self->dataFormat.mChannelsPerFrame);
buffer->mAudioDataByteSize = resultFrames * self->dataFormat.mBytesPerFrame;//buffer->mAudioDataBytesCapacity;
AudioQueueEnqueueBuffer(queue, buffer, 0, NULL);
}
示例2: auAudioCallback
void* auAudioCallback(void* SELF)
{
Audio* self = (Audio*)SELF;
self->threadIsRunning = self->threadShouldContinueRunning = YES;
signal(SIGPIPE, SIG_IGN);
int success = YES;
while(self->threadShouldContinueRunning)
{
if(!self->isOutput)
success = auTransferData(self, snd_pcm_readi);
if(success)
self->audioCallback(SELF, self->sampleBuffer, self->bufferNumFrames, self->numChannels);
if(self->isOutput)
success = auTransferData(self, (snd_pcm_sframes_t (*)(snd_pcm_t*, void*, snd_pcm_uframes_t)) snd_pcm_writei);
if(!success) break;
}
self->threadIsRunning = NO;
return NULL;
}