callback - AURenderCallbackStruct in Swift -


i have objective-c example aurendercallbackstruct, , 1 in swift. read it's not posible, correct?

thank you.

it's possible. use following code audio unit settings.

init() {      var status: osstatus      {         try avaudiosession.sharedinstance().setpreferrediobufferduration(preferrediobufferduration)     } catch let error nserror {         print(error)     }       var desc: audiocomponentdescription = audiocomponentdescription()     desc.componenttype = kaudiounittype_output     desc.componentsubtype = kaudiounitsubtype_voiceprocessingio     desc.componentflags = 0     desc.componentflagsmask = 0     desc.componentmanufacturer = kaudiounitmanufacturer_apple      let inputcomponent: audiocomponent = audiocomponentfindnext(nil, &desc)      status = audiocomponentinstancenew(inputcomponent, &audiounit)     checkstatus(status)      var flag = uint32(1)     status = audiounitsetproperty(audiounit, kaudiooutputunitproperty_enableio, kaudiounitscope_input, kinputbus, &flag, uint32(sizeof(uint32)))     checkstatus(status)      status = audiounitsetproperty(audiounit, kaudiooutputunitproperty_enableio, kaudiounitscope_output, koutputbus, &flag, uint32(sizeof(uint32)))     checkstatus(status)      var audioformat: audiostreambasicdescription! = audiostreambasicdescription()     audioformat.msamplerate = 8000     audioformat.mformatid = kaudioformatlinearpcm     audioformat.mformatflags = kaudioformatflagissignedinteger | kaudioformatflagispacked     audioformat.mframesperpacket = 1     audioformat.mchannelsperframe = 1     audioformat.mbitsperchannel = 16     audioformat.mbytesperpacket = 2     audioformat.mbytesperframe = 2      status = audiounitsetproperty(audiounit, kaudiounitproperty_streamformat, kaudiounitscope_output, kinputbus, &audioformat, uint32(sizeof(uint32)))     checkstatus(status)       try! avaudiosession.sharedinstance().setcategory(avaudiosessioncategoryplayandrecord)     status = audiounitsetproperty(audiounit, kaudiounitproperty_streamformat, kaudiounitscope_input, koutputbus, &audioformat, uint32(sizeof(uint32)))     checkstatus(status)       // set input/recording callback     var inputcallbackstruct = aurendercallbackstruct(inputproc: recordingcallback, inputprocrefcon: unsafemutablepointer(unsafeaddressof(self)))     audiounitsetproperty(audiounit, audiounitpropertyid(kaudiooutputunitproperty_setinputcallback), audiounitscope(kaudiounitscope_global), 1, &inputcallbackstruct, uint32(sizeof(aurendercallbackstruct)))       // set output/renderar/playback callback     var rendercallbackstruct = aurendercallbackstruct(inputproc: playbackcallback, inputprocrefcon: unsafemutablepointer(unsafeaddressof(self)))     audiounitsetproperty(audiounit, audiounitpropertyid(kaudiounitproperty_setrendercallback), audiounitscope(kaudiounitscope_global), 0, &rendercallbackstruct, uint32(sizeof(aurendercallbackstruct)))       flag = 0     status = audiounitsetproperty(audiounit, kaudiounitproperty_shouldallocatebuffer, kaudiounitscope_output, kinputbus, &flag, uint32(sizeof(uint32))) } 

Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -