common: prevent buffer overflow
[supercollider.git] / server / scsynth / SC_AU.cpp
blobd25e3b99fad4ed3a1add5332693d5d5d7c54eeff
1 /*
2 AudioUnits driver interface.
3 Copyright (c) 2006-2008 Gerard Roma.
5 ====================================================================
7 SuperCollider real time audio synthesis system
8 Copyright (c) 2002 James McCartney. All rights reserved.
9 http://www.audiosynth.com
11 This program is free software; you can redistribute it and/or modify
12 it under the terms of the GNU General Public License as published by
13 the Free Software Foundation; either version 2 of the License, or
14 (at your option) any later version.
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with this program; if not, write to the Free Software
23 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
25 #if SC_AUDIO_API == SC_AUDIO_API_AUDIOUNITS
26 #include "SC_AU.h"
29 void AUCallback(SC_AUAudioDriver *driver,AudioBufferList* in, AudioBufferList* out, AudioTimeStamp* inTimeStamp, UInt32 inFramesToProcess, Float64 sampleRate, int64 oscTime){
30 driver->Callback(in, out, inTimeStamp, inFramesToProcess, sampleRate, oscTime);
33 void sc_SetDenormalFlags();
35 SC_AudioDriver* SC_NewAudioDriver(struct World *inWorld)
37 return new SC_AUAudioDriver(inWorld);
40 SC_AUAudioDriver::SC_AUAudioDriver(struct World *inWorld): SC_CoreAudioDriver(inWorld){}
42 SC_AUAudioDriver::~SC_AUAudioDriver(){}
45 bool SC_AUAudioDriver::DriverSetup(int* outNumSamples, double* outSampleRate)
47 // params are set into the wolrd options at AU initialize
48 if(!mPreferredSampleRate && !mPreferredHardwareBufferFrameSize) return false;
49 *outSampleRate = mPreferredSampleRate;
50 *outNumSamples = mPreferredHardwareBufferFrameSize;
51 return true;
54 bool SC_AUAudioDriver::DriverStart()
56 return true;
59 bool SC_AUAudioDriver::DriverStop()
61 return true;
65 void SC_AUAudioDriver::Callback(const AudioBufferList* in, AudioBufferList* out, AudioTimeStamp* inTimeStamp, UInt32 inFramesToProcess, Float64 sampleRate, int64 oscTime){
66 this->mNumSamplesPerCallback = inFramesToProcess;
67 this->mOSCincrement = (int64)(this->mOSCincrementNumerator / sampleRate);
68 this->Run(in, out, oscTime);
70 #endif