// // libtgvoip is free and unencumbered public domain software. // For more information, see http://unlicense.org or the UNLICENSE file // you should have received with this source code distribution. // #include #include #include #include "AudioOutputAudioUnit.h" #include "../../tools/logging.h" #include "AudioUnitIO.h" #define BUFFER_SIZE 960 using namespace tgvoip; using namespace tgvoip::audio; AudioOutputAudioUnit::AudioOutputAudioUnit(std::string deviceID, AudioUnitIO* io){ isPlaying=false; remainingDataSize=0; this->io=io; #if TARGET_OS_OSX io->SetCurrentDevice(false, deviceID); #endif } AudioOutputAudioUnit::~AudioOutputAudioUnit(){ } void AudioOutputAudioUnit::Start(){ isPlaying=true; io->EnableOutput(true); } void AudioOutputAudioUnit::Stop(){ isPlaying=false; io->EnableOutput(false); } bool AudioOutputAudioUnit::IsPlaying(){ return isPlaying; } void AudioOutputAudioUnit::HandleBufferCallback(AudioBufferList *ioData){ int i; for(i=0;imNumberBuffers;i++){ AudioBuffer buf=ioData->mBuffers[i]; if(!isPlaying){ memset(buf.mData, 0, buf.mDataByteSize); return; } #if TARGET_OS_OSX unsigned int k; while(remainingDataSize(buf.mData); int16_t* src=reinterpret_cast(remainingData); for(k=0;kSetCurrentDevice(false, deviceID); } #endif