다음 코드는 과거에 저에게 도움이되었습니다. 운이없이 iOS4로 지금 시도 중입니다. 시뮬레이터에서 작동하지만 기기 자체에서 아무 것도 듣지 못합니다. 먼저 NSMutableData
변수에 몇 개의 샘플을 기록한 다음 다시 재생하려고합니다.AudioQueue 및 iOS4?
Apple에서 SpeakHere 샘플을 시도해 보았습니다. - 작동하지만 파일이 아닌 메모리에서 재생됩니다.
어떤 아이디어가 없습니까?
이(1) 확인 장치가 음소거 상태가 아닌지 확인하고 볼륨은 최대
(2) 확인 결과 코드입니다 : 내가 제안 할 수
AudioSessionInitialize(NULL, NULL, NULL, NULL);
UInt32 sessionCategory = kAudioSessionCategory_PlayAndRecord;
AudioSessionSetProperty(kAudioSessionProperty_AudioCategory, sizeof(sessionCategory), &sessionCategory);
AudioSessionSetActive(true);
AudioQueueNewOutput(&m_format,&OutputCallback,self,CFRunLoopGetCurrent(), kCFRunLoopCommonModes,0,&m_device);
AudioQueueBufferRef nBuffer=NULL;
AudioQueueAllocateBuffer(m_device,[data length],&nBuffer);
nBuffer->mAudioDataByteSize=[data length];
[data getBytes:(nBuffer->mAudioData) length:(nBuffer->mAudioDataByteSize)];
AudioQueueEnqueueBuffer(m_device,nBuffer,0,NULL);
AudioQueueStart(m_device,NULL);