@@ -221,9 +221,11 @@ static OSStatus BlackHole_Initialize(AudioServerPlugInDriverRef inDriver, AudioS
221221 // calculate the host ticks per frame
222222 struct mach_timebase_info theTimeBaseInfo ;
223223 mach_timebase_info (& theTimeBaseInfo );
224- Float64 theHostClockFrequency = theTimeBaseInfo .numer / theTimeBaseInfo .denom ;
224+ Float64 theHostClockFrequency = ( Float64 ) theTimeBaseInfo .denom / ( Float64 ) theTimeBaseInfo .numer ;
225225 theHostClockFrequency *= 1000000000.0 ;
226226 gDevice_HostTicksPerFrame = theHostClockFrequency / gDevice_SampleRate ;
227+
228+ // DebugMsg("BlackHole theTimeBaseInfo.numer: %u \t theTimeBaseInfo.denom: %u", theTimeBaseInfo.numer, theTimeBaseInfo.denom);
227229
228230Done :
229231 return theAnswer ;
@@ -346,12 +348,14 @@ static OSStatus BlackHole_PerformDeviceConfigurationChange(AudioServerPlugInDriv
346348 // recalculate the state that depends on the sample rate
347349 struct mach_timebase_info theTimeBaseInfo ;
348350 mach_timebase_info (& theTimeBaseInfo );
349- Float64 theHostClockFrequency = theTimeBaseInfo .numer / theTimeBaseInfo .denom ;
351+ Float64 theHostClockFrequency = ( Float64 ) theTimeBaseInfo .numer / ( Float64 ) theTimeBaseInfo .denom ;
350352 theHostClockFrequency *= 1000000000.0 ;
351353 gDevice_HostTicksPerFrame = theHostClockFrequency / gDevice_SampleRate ;
352354
353355 // unlock the state mutex
354356 pthread_mutex_unlock (& gPlugIn_StateMutex );
357+
358+ // DebugMsg("BlackHole theTimeBaseInfo.numer: %u \t theTimeBaseInfo.denom: %u", theTimeBaseInfo.numer, theTimeBaseInfo.denom);
355359
356360Done :
357361 return theAnswer ;
@@ -3789,6 +3793,8 @@ static OSStatus BlackHole_GetZeroTimeStamp(AudioServerPlugInDriverRef inDriver,
37893793 * outSampleTime = gDevice_NumberTimeStamps * kDevice_RingBufferSize ;
37903794 * outHostTime = gDevice_AnchorHostTime + (((Float64 )gDevice_NumberTimeStamps ) * theHostTicksPerRingBuffer );
37913795 * outSeed = 1 ;
3796+
3797+ // DebugMsg("SampleTime: %f \t HostTime: %llu", *outSampleTime, *outHostTime);
37923798
37933799 // unlock the state lock
37943800 pthread_mutex_unlock (& gDevice_IOMutex );
@@ -3894,6 +3900,10 @@ static OSStatus BlackHole_DoIOOperation(AudioServerPlugInDriverRef inDriver, Aud
38943900 // write to the ioMainBuffer
38953901 buffer [frame * NUMBER_OF_CHANNELS + channel ] = ringBuffer [((mSampleTime + frame )%kDevice_RingBufferSize )* NUMBER_OF_CHANNELS + channel ];
38963902 }
3903+ else
3904+ {
3905+ buffer [frame * NUMBER_OF_CHANNELS + channel ] = 0 ;
3906+ }
38973907
38983908 // clear ring buffer after 8192 samples.
38993909 ringBuffer [((mSampleTime + frame - 8192 )%kDevice_RingBufferSize )* NUMBER_OF_CHANNELS + channel ] = 0 ;
@@ -3919,6 +3929,10 @@ static OSStatus BlackHole_DoIOOperation(AudioServerPlugInDriverRef inDriver, Aud
39193929 // write to internal ring buffer
39203930 ringBuffer [((mSampleTime + frame )%kDevice_RingBufferSize )* NUMBER_OF_CHANNELS + channel ] += buffer [frame * NUMBER_OF_CHANNELS + channel ] * gVolume_Output_Master_Value ;
39213931 }
3932+ else
3933+ {
3934+ buffer [frame * NUMBER_OF_CHANNELS + channel ] = 0 ;
3935+ }
39223936
39233937 // clear ring buffer after 8192 samples.
39243938 ringBuffer [((mSampleTime + frame - 8192 )%kDevice_RingBufferSize )* NUMBER_OF_CHANNELS + channel ] = 0 ;
0 commit comments