2010-08-01 2 views
0

iPhone 실험에 소리가 출력되지 않고 아이디어가 없습니다. AudioQueue가 소리를 출력하지 않습니다.

여기에 다음 코드

// 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); 

내가 리니어 PCM 16 비트 44hz를 출력한다 사용하고 라이브러리를 사용하여 오디오 큐 버퍼

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 설정을 오디오 큐를 채우기 위해 내 콜백입니다.

답변

0

보통 3 개의 버퍼를 사용합니다. 하나가 재생되면 다른 하나는 코드로 채워지기 때문에 최소 2 개가 필요합니다. 하나만있는 경우 동일한 버퍼를 채우고 다시 대기열에 넣고 재생을 원활하게 할 시간이 없습니다. 따라서 버퍼가 없어서 대기열이 멈추는 것 같습니다.

0

두 개의 버퍼를 대신 할당하십시오.

AudioQueues은 매우 까다 롭습니다.