I need to get audio from a microphone and switch to another device using tcp connection. I am not sure if it is possible to play AudioBuffer from AudioQueue.
I am currently getting a buffer with the code below:
void AudioInputCallback(
void *inUserData,
AudioQueueRef inAQ,
AudioQueueBufferRef inBuffer,
const AudioTimeStamp *inStartTime,
UInt32 inNumberPacketDescriptions,
const AudioStreamPacketDescription *inPacketDescs)
{
AudioRecorder *self = (AudioRecorder *)inUserData;
if(!self.recordState.recording)
{
NSLog(@"[ AudioRecorder ] AudioInputCallback not recording");
return;
}
if(inNumberPacketDescriptions > 0)
{
NSData *data = [[NSData alloc] initWithBytes:inBuffer->mAudioData length:inBuffer->mAudioDataByteSize * 2];
[self.delegate didReceivedAudioData:data];
[data release];
}
}
This block simply pushes mAudioData towards NSData, NSData is a key data type for transferring data between devices.
Now I do not know how to run this mAudioData on another device. Another thing is how to receive sound continuously, when all the buffers are full, I no longer receive data, I just need to clear the buffer that I assume.
Any idea is welcome, thanks!
source
share