0

I use AUGraph, which contains several (10, for example) players, mixer and output. If I turn on players with delay about 0,2sec - it's ok, they all play, but if I turn on them at the same time, only 3-4 players play.

It's ok, all players play, but with delay:

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

It's not ok, only 2-3 players play, but synchronously:

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

In [player play] method:

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

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

AudioUnitSetProperty returns noErr.

It seems that there is conflict in AudioUnitSetProperty with several threads, which I can't control.

Any ideas?

Dmitrii
  • 85
  • 1
  • 7

1 Answers1

0

Adding kAudioUnitProperty_ScheduledFilePrime setup before kAudioUnitProperty_ScheduleStartTimeStamp solved a problem.

    UInt32 defaultVal = 0;
    AudioUnitSetProperty(audioUnit,
                         kAudioUnitProperty_ScheduledFilePrime,
                         kAudioUnitScope_Global,
                         0,
                         &defaultVal,
                         sizeof(defaultVal));
Dmitrii
  • 85
  • 1
  • 7