IOS: playing PCM buffers from a stream

I get a series of UDP packets from a socket containing encoded PCM buffers. After decoding them, I still have the int16 * sound buffer, which I would like to play right away.

The supposed logic looks something like this:

init(){
   initTrack(track, output, channels, sample_rate, ...);
}

onReceiveBufferFromSocket(NSData data){
   //Decode the buffer
   int16 * buf = handle_data(data);

   //Play data
   write_to_track(track, buf, length_of_buf, etc);
}

I am not sure about everything related to playing buffers. On Android, I can achieve this by creating an AudioTrack object, setting it up, specifying the sample rate, format, channels, etc., and then just calling the write method with a buffer (for example, I want it I could in my pseudo-code above), but on iOS I'm a little behind.

Audio File Stream Services, , - , , , . (, , , ), .

, .

+5
2

UDP . - , .

, , Audio Unit. - .

. , Audio Unit.

+4

All Articles