2017-10-25 18 views
0

필자는 AUGraph를 사용합니다.이 플레이어에는 몇 가지 (예 : 10 개) 플레이어, 믹서 및 출력이 있습니다. 지연 시간이 0.2 초인 플레이어를 켜면 모두 정상적으로 작동하지만, 동시에 켜면 3-4 명이 재생됩니다. 기적AUGraph에서 여러 플레이어의 동기식 재생

for(int i=0; i<10; i++){ 
     [players[i] play]; 
     usleep(200000); 
    } 

그것은, 2-3 플레이어가되지 확인 연주,하지만 :

괜찮아, 모든 선수,하지만 지연 플레이

for(int i=0; i<10; i++){ 
     [players[i] play]; 
    } 

[player play] 방법 :

AudioTimeStamp startTime; 
    memset (&startTime, 0, sizeof(startTime)); 
    startTime.mFlags = kAudioTimeStampSampleTimeValid; 
    startTime.mSampleTime = -1; 

    AudioUnitSetProperty(audioUnit, 
     kAudioUnitProperty_ScheduleStartTimeStamp, 
     kAudioUnitScope_Global, 
     0, 
     &startTime, 
     sizeof(startTime)); 

AudioUnitSetProperty은 norr을 반환합니다.

AudioUnitSetProperty에 제어 할 수없는 여러 스레드가 충돌하는 것 같습니다.

아이디어가 있으십니까?

답변

0

kAudioUnitProperty_ScheduledFilePrime 설정을 추가하기 전에 kAudioUnitProperty_ScheduleStartTimeStamp가 문제를 해결했습니다.

UInt32 defaultVal = 0; 
    AudioUnitSetProperty(audioUnit, 
         kAudioUnitProperty_ScheduledFilePrime, 
         kAudioUnitScope_Global, 
         0, 
         &defaultVal, 
         sizeof(defaultVal));