PatrickSCLin
PatrickSCLin

Reputation: 1449

How to play audio buffer which from remote side for iOS?

I was post a question which about fetch AudioBuffer from Recorder,

my relate question: Is there any high level Audio Queue Record Service Library for iOS?

I can fetch the buffer from recorder and put it to a NSData, and then send it by udp socket.

but how to using the buffer on the other one iOS device ?

is there any way to play the buffer ?

I had research some example code but most of them just playing when recorder recording.

Is there any more detail tutorial which for play a buffer from remote ?

Update: I just resolved it now

the key function is the play callback function!

static OSStatus playbackCallback(void *inRefCon, 
                                  AudioUnitRenderActionFlags *ioActionFlags, 
                                  const AudioTimeStamp *inTimeStamp, 
                                  UInt32 inBusNumber, 
                                  UInt32 inNumberFrames, 
                                  AudioBufferList *ioData) {    
    // Notes: ioData contains buffers (may be more than one!)
    // Fill them up as much as you can. Remember to set the size value in each buffer to match how
    // much data is in the buffer.
    return noErr;
}

BTW, should be always check the low level stuffs what you using!

ex: malloc memcpy free

Upvotes: 0

Views: 1514

Answers (1)

DShah
DShah

Reputation: 9866

If I understood your question then I think this link could help you : https://github.com/mattgallagher/AudioStreamer

AudioStreamer is made for playing remote audio while streaming.

Upvotes: 1

Related Questions