I have problems getting sound on my iPhone experiment, and I have no ideas.
Here is my callback to populate the audio queue buffer
void AudioOutputCallback(void *user, AudioQueueRef refQueue, AudioQueueBufferRef inBuffer) { NSLog(@"callback called"); inBuffer->mAudioDataByteSize = 1024; gme_play((Music_Emu*)user, 1024, (short *)inBuffer->mAudioData); AudioQueueEnqueueBuffer(refQueue, inBuffer, 0, NULL); }
I am tuning the audio queue using the following snippet
// Create stream description AudioStreamBasicDescription streamDescription; streamDescription.mSampleRate = 44100; streamDescription.mFormatID = kAudioFormatLinearPCM; streamDescription.mFormatFlags = kLinearPCMFormatFlagIsSignedInteger | kLinearPCMFormatFlagIsPacked; streamDescription.mBytesPerPacket = 1024; streamDescription.mFramesPerPacket = 1024 / 4; streamDescription.mBytesPerFrame = 2 * sizeof(short); streamDescription.mChannelsPerFrame = 2; streamDescription.mBitsPerChannel = 16; AudioQueueNewOutput(&streamDescription, AudioOutputCallback, theEmu, NULL, NULL, 0, &theAudioQueue); OSStatus errorCode = AudioQueueAllocateBuffer(theAudioQueue, 1024, &someBuffer); if( errorCode ) { NSLog(@"Cannot allocate buffer"); } AudioOutputCallback(theEmu, theAudioQueue, someBuffer); AudioQueueSetParameter(theAudioQueue, kAudioQueueParam_Volume, 1.0); AudioQueueStart(theAudioQueue, NULL);
The library I use outputs linear PCM 16bit 44hz.
source share