2012-05-16 3 views
12

OpenAL을 사용하여 오디오 재생을 위해 OpenAL 3D 게임을 만들었습니다. 오디오 장치가 초기화되기 전에 "홈"버튼을 누르면 오디오 손실 문제가 발생합니다. 오디오 세션 인터럽트 처리기에 연결하려고했지만 콜백이 호출되지 않습니다. 내 신청서를 최소화하거나 최대화하더라도 상관 없습니다. 내 "OpenALInterruptionListener"가 호출되지 않습니다.오디오 중단을 올바르게 처리하는 방법은 무엇입니까?

내가 뭘 잘못하고 있니?

AudioSessionInitialize(NULL, NULL, OpenALInterriptionListener, this); 

void OpenALInterriptionListener(void * inClientData, UInt32 inInterruptionState) 
{ 
    OpenALDevice * device = (OpenALDevice *) inClientData; 

    if (inInterruptionState == kAudioSessionBeginInterruption) 
    { 
      alcSuspendContext(_context); 
      alcMakeContextCurrent(_context); 
      AudioSessionSetActive(false); 
    } 
    else if (inInterruptionState == kAudioSessionEndInterruption) 
    { 
      UInt32 sessionCategory = kAudioSessionCategory_AmbientSound; 
      AudioSessionSetProperty(kAudioSessionProperty_AudioCategory, sizeof(sessionCategory), &sessionCategory); 
      AudioSessionSetActive(true);  
      alcMakeContextCurrent(_context); 
      alcProcessContext(_context); 
    } 
} 

답변

0

것은

void OpenALInterriptionListener(void *inClientData, UInt32 inInterruptionState) 
{ 
    OpenALDevice * device = (OpenALDevice *) inClientData; 
    OSStatus nResult; 

    if(inInterruptionState == kAudioSessionBeginInterruption) 
    { 
     alcMakeContextCurrent(NULL);  
    } 
    else if(inInterruptionState == kAudioSessionEndInterruption) 
    { 
     nResult = AudioSessionSetActive(true); 

     if(nResult) 
     { 
      // "Error setting audio session active" 
     } 

     alcMakeContextCurrent(device->GetContext()); 
    } 
} 
+0

[http://benbritten.com/2009/02/02/restarting-openal-after-application-interruption-on-the-iphone/](http://benbritten.com/2009/02/02/) 재시작 - 오프 - 애프터 - 애플 리케이션 중단 -에 - 아이폰 /) – james82345

1

오디오 정전와 IOS에 문제가 현재이 있음을 유의하시기 바랍니다() alcMakeContextCurrent에 NULL를 사용해보십시오. 중단 알림은 정상이지만 종료 오디오 중단 알림은 항상 작동하지 않습니다. 이 문제에 대한 Apple의 버그가 있으며 응답하지 않았습니다.