ios - Unable to AUGraphStart a simple Voice-Processing I/O with 2 render callbacks -
i have audio graph set 1 voice-processing i/o. there render callbacks both input , output bus , appropriate audiostreambasicdescription applied both inward facing sides of bus.
so audio graph setup so
input
- user's voice-->mic-->send pcm frame on network in input callback.
output
- network-->tpcircularbuffer.... pulled output side of iounit through callback.
now whenever try , start graph kaudioformatunsupporteddataformaterror. searching around, error pops because trying write invalid file format. can see above, not writing files?? gives? i'm guessing error description, there wrong audiostreambasicdescription, wouldn't give me error when setting up?
this how stream being setup. both functions return noerr.
- (bool)setupstreamformat:(nserror **)error { uint32 bytespersample = sizeof(sint16); double samplerate = [avaudiosession sharedinstance].samplerate; self.currentaudiosamplerate = samplerate; audiostreambasicdescription asbd = {0}; asbd.msamplerate = samplerate; asbd.mformatid = kaudioformatlinearpcm; asbd.mformatflags = klinearpcmformatflagissignedinteger; asbd.mchannelsperframe = 2; asbd.mbytesperframe = bytespersample; asbd.mbitsperchannel = 8 * bytespersample; asbd.mframesperpacket = 1; asbd.mbytesperpacket = bytespersample; osstatus status = audiounitsetproperty(self.iounit, kaudiounitproperty_streamformat, kaudiounitscope_output, kinputbus, &asbd, sizeof(asbd)); if (status != noerr) { [self fillerror:error withcode:status description:@"stream format" failurereason:@"failed setup input stream format"]; return no; } status = audiounitsetproperty(self.iounit, kaudiounitproperty_streamformat, kaudiounitscope_input, koutputbus, &asbd, sizeof(asbd)); if (status != noerr) { [self fillerror:error withcode:status description:@"stream format" failurereason:@"failed setup output stream format"]; return no; } return yes; }
i figured out answer problem. apparently absd had setup incorrect.the format should of been below:
audiostreambasicdescription asbd = {0}; asbd.msamplerate = self.currentaudiosamplerate; asbd.mformatid = kaudioformatlinearpcm; asbd.mformatflags = klinearpcmformatflagissignedinteger; asbd.mchannelsperframe = 2; asbd.mbytesperframe = bytespersample * 2; asbd.mbitsperchannel = 8 * bytespersample; asbd.mframesperpacket = 1; asbd.mbytesperpacket = bytespersample * 2;
Comments
Post a Comment