2010-03-05 07:05:38 +01:00
|
|
|
/******************************************************************************\
|
2011-03-31 20:25:14 +02:00
|
|
|
* Copyright (c) 2004-2011
|
2010-03-05 07:05:38 +01:00
|
|
|
*
|
|
|
|
* Author(s):
|
|
|
|
* Volker Fischer
|
|
|
|
*
|
|
|
|
******************************************************************************
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it under
|
|
|
|
* the terms of the GNU General Public License as published by the Free Software
|
|
|
|
* Foundation; either version 2 of the License, or (at your option) any later
|
|
|
|
* version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
|
|
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
|
|
|
* details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along with
|
|
|
|
* this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*
|
|
|
|
\******************************************************************************/
|
|
|
|
|
|
|
|
#include "sound.h"
|
|
|
|
|
2010-03-05 21:19:12 +01:00
|
|
|
|
|
|
|
/* Implementation *************************************************************/
|
|
|
|
void CSound::OpenCoreAudio()
|
|
|
|
{
|
2010-03-09 20:19:10 +01:00
|
|
|
UInt32 size;
|
2010-03-13 12:04:29 +01:00
|
|
|
ComponentResult err;
|
2010-03-09 20:19:10 +01:00
|
|
|
|
|
|
|
// open the default unit
|
|
|
|
ComponentDescription desc;
|
2010-03-05 21:19:12 +01:00
|
|
|
desc.componentType = kAudioUnitType_Output;
|
2010-03-09 20:19:10 +01:00
|
|
|
desc.componentSubType = kAudioUnitSubType_HALOutput;
|
|
|
|
desc.componentManufacturer = kAudioUnitManufacturer_Apple;
|
2010-03-05 21:19:12 +01:00
|
|
|
desc.componentFlags = 0;
|
|
|
|
desc.componentFlagsMask = 0;
|
|
|
|
|
2010-03-09 20:19:10 +01:00
|
|
|
Component comp = FindNextComponent ( NULL, &desc );
|
2010-03-05 21:19:12 +01:00
|
|
|
if ( comp == NULL )
|
|
|
|
{
|
|
|
|
throw CGenErr ( tr ( "No CoreAudio next component found" ) );
|
|
|
|
}
|
|
|
|
|
2010-03-13 12:04:29 +01:00
|
|
|
if ( OpenAComponent ( comp, &audioInputUnit ) )
|
|
|
|
{
|
|
|
|
throw CGenErr ( tr ( "CoreAudio creating input component instance failed" ) );
|
|
|
|
}
|
2010-03-11 20:35:19 +01:00
|
|
|
|
2010-03-13 12:04:29 +01:00
|
|
|
if ( OpenAComponent ( comp, &audioOutputUnit ) )
|
|
|
|
{
|
|
|
|
throw CGenErr ( tr ( "CoreAudio creating output component instance failed" ) );
|
|
|
|
}
|
2010-03-10 22:40:47 +01:00
|
|
|
|
|
|
|
// we enable input and disable output for input component
|
2010-03-09 21:36:35 +01:00
|
|
|
UInt32 enableIO = 1;
|
2010-03-10 22:40:47 +01:00
|
|
|
err = AudioUnitSetProperty ( audioInputUnit,
|
2010-03-11 20:35:19 +01:00
|
|
|
kAudioOutputUnitProperty_EnableIO,
|
|
|
|
kAudioUnitScope_Input,
|
|
|
|
1, // input element
|
|
|
|
&enableIO,
|
|
|
|
sizeof ( enableIO ) );
|
2010-03-09 20:19:10 +01:00
|
|
|
|
2010-03-09 21:36:35 +01:00
|
|
|
enableIO = 0;
|
2010-03-10 22:40:47 +01:00
|
|
|
err = AudioUnitSetProperty ( audioInputUnit,
|
2010-03-11 20:35:19 +01:00
|
|
|
kAudioOutputUnitProperty_EnableIO,
|
|
|
|
kAudioUnitScope_Output,
|
|
|
|
0, // output element
|
|
|
|
&enableIO,
|
|
|
|
sizeof ( enableIO ) );
|
2010-03-09 20:19:10 +01:00
|
|
|
|
2010-03-10 22:40:47 +01:00
|
|
|
// set input device
|
|
|
|
size = sizeof ( AudioDeviceID );
|
|
|
|
if ( AudioHardwareGetProperty ( kAudioHardwarePropertyDefaultInputDevice,
|
|
|
|
&size,
|
2010-03-11 20:12:30 +01:00
|
|
|
&audioInputDevice ) )
|
2010-03-10 22:40:47 +01:00
|
|
|
{
|
|
|
|
throw CGenErr ( tr ( "CoreAudio input AudioHardwareGetProperty call failed" ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( AudioUnitSetProperty ( audioInputUnit,
|
|
|
|
kAudioOutputUnitProperty_CurrentDevice,
|
|
|
|
kAudioUnitScope_Global,
|
|
|
|
1,
|
2010-03-11 20:12:30 +01:00
|
|
|
&audioInputDevice,
|
|
|
|
sizeof ( audioInputDevice ) ) )
|
2010-03-10 22:40:47 +01:00
|
|
|
{
|
|
|
|
throw CGenErr ( tr ( "CoreAudio input AudioUnitSetProperty call failed" ) );
|
|
|
|
}
|
|
|
|
|
2010-03-09 21:36:35 +01:00
|
|
|
// set up a callback function for new input data
|
2010-03-05 21:19:12 +01:00
|
|
|
AURenderCallbackStruct input;
|
2010-03-10 22:40:47 +01:00
|
|
|
input.inputProc = processInput;
|
2010-03-05 21:19:12 +01:00
|
|
|
input.inputProcRefCon = this;
|
|
|
|
|
2010-03-10 22:40:47 +01:00
|
|
|
if ( AudioUnitSetProperty ( audioInputUnit,
|
2010-03-11 08:03:04 +01:00
|
|
|
kAudioOutputUnitProperty_SetInputCallback,
|
2010-03-09 20:19:10 +01:00
|
|
|
kAudioUnitScope_Global,
|
2010-03-05 21:19:12 +01:00
|
|
|
0,
|
|
|
|
&input,
|
2010-03-09 20:19:10 +01:00
|
|
|
sizeof ( input ) ) )
|
2010-03-05 21:19:12 +01:00
|
|
|
{
|
|
|
|
throw CGenErr ( tr ( "CoreAudio audio unit set property failed" ) );
|
|
|
|
}
|
|
|
|
|
2010-03-10 22:40:47 +01:00
|
|
|
// set output device
|
2010-03-09 20:19:10 +01:00
|
|
|
size = sizeof ( AudioDeviceID );
|
2010-03-10 22:40:47 +01:00
|
|
|
if ( AudioHardwareGetProperty ( kAudioHardwarePropertyDefaultOutputDevice,
|
2010-03-09 20:19:10 +01:00
|
|
|
&size,
|
2010-03-11 20:12:30 +01:00
|
|
|
&audioOutputDevice ) )
|
2010-03-09 20:19:10 +01:00
|
|
|
{
|
2010-03-10 22:40:47 +01:00
|
|
|
throw CGenErr ( tr ( "CoreAudio output AudioHardwareGetProperty call failed" ) );
|
2010-03-09 20:19:10 +01:00
|
|
|
}
|
2010-03-05 21:19:12 +01:00
|
|
|
|
2010-03-10 22:40:47 +01:00
|
|
|
if ( AudioUnitSetProperty ( audioOutputUnit,
|
2010-03-09 20:19:10 +01:00
|
|
|
kAudioOutputUnitProperty_CurrentDevice,
|
|
|
|
kAudioUnitScope_Global,
|
|
|
|
0,
|
2010-03-11 20:12:30 +01:00
|
|
|
&audioOutputDevice,
|
|
|
|
sizeof ( audioOutputDevice ) ) )
|
2010-03-09 20:19:10 +01:00
|
|
|
{
|
2010-03-10 22:40:47 +01:00
|
|
|
throw CGenErr ( tr ( "CoreAudio output AudioUnitSetProperty call failed" ) );
|
2010-03-13 12:04:29 +01:00
|
|
|
}
|
2010-03-10 22:40:47 +01:00
|
|
|
|
|
|
|
// set up a callback function for new output data
|
|
|
|
AURenderCallbackStruct output;
|
|
|
|
output.inputProc = processOutput;
|
|
|
|
output.inputProcRefCon = this;
|
|
|
|
|
|
|
|
if ( AudioUnitSetProperty ( audioOutputUnit,
|
2010-03-11 08:03:04 +01:00
|
|
|
kAudioUnitProperty_SetRenderCallback,
|
2010-03-10 22:40:47 +01:00
|
|
|
kAudioUnitScope_Global,
|
|
|
|
0,
|
|
|
|
&output,
|
|
|
|
sizeof ( output ) ) )
|
|
|
|
{
|
|
|
|
throw CGenErr ( tr ( "CoreAudio audio unit set property failed" ) );
|
2010-03-09 20:19:10 +01:00
|
|
|
}
|
2010-03-05 21:19:12 +01:00
|
|
|
|
2010-03-05 22:18:11 +01:00
|
|
|
// set up stream format
|
|
|
|
AudioStreamBasicDescription streamFormat;
|
2011-03-31 20:25:14 +02:00
|
|
|
streamFormat.mSampleRate = SYSTEM_SAMPLE_RATE_HZ;
|
2010-03-05 22:18:11 +01:00
|
|
|
streamFormat.mFormatID = kAudioFormatLinearPCM;
|
|
|
|
streamFormat.mFormatFlags = kAudioFormatFlagIsSignedInteger;
|
2010-03-09 20:19:10 +01:00
|
|
|
streamFormat.mFramesPerPacket = 1;
|
|
|
|
streamFormat.mBytesPerFrame = 4;
|
|
|
|
streamFormat.mBytesPerPacket = 4;
|
2010-03-05 22:18:11 +01:00
|
|
|
streamFormat.mChannelsPerFrame = 2; // stereo
|
|
|
|
streamFormat.mBitsPerChannel = 16;
|
2010-03-09 20:19:10 +01:00
|
|
|
|
|
|
|
// our output
|
2010-03-10 22:40:47 +01:00
|
|
|
if ( AudioUnitSetProperty ( audioOutputUnit,
|
2010-03-05 22:18:11 +01:00
|
|
|
kAudioUnitProperty_StreamFormat,
|
|
|
|
kAudioUnitScope_Input,
|
|
|
|
0,
|
|
|
|
&streamFormat,
|
|
|
|
sizeof(streamFormat) ) )
|
|
|
|
{
|
|
|
|
throw CGenErr ( tr ( "CoreAudio stream format set property failed" ) );
|
|
|
|
}
|
2010-03-05 21:19:12 +01:00
|
|
|
|
2010-03-09 20:19:10 +01:00
|
|
|
// our input
|
2010-03-10 22:40:47 +01:00
|
|
|
if ( AudioUnitSetProperty ( audioInputUnit,
|
2010-03-09 20:19:10 +01:00
|
|
|
kAudioUnitProperty_StreamFormat,
|
|
|
|
kAudioUnitScope_Output,
|
|
|
|
1,
|
|
|
|
&streamFormat,
|
|
|
|
sizeof(streamFormat) ) )
|
|
|
|
{
|
|
|
|
throw CGenErr ( tr ( "CoreAudio stream format set property failed" ) );
|
|
|
|
}
|
|
|
|
|
2010-03-13 12:04:29 +01:00
|
|
|
// check input device sample rate
|
2010-03-11 08:03:04 +01:00
|
|
|
size = sizeof ( Float64 );
|
|
|
|
Float64 inputSampleRate;
|
|
|
|
AudioUnitGetProperty ( audioInputUnit,
|
2010-03-13 12:04:29 +01:00
|
|
|
kAudioUnitProperty_SampleRate,
|
2010-03-11 08:03:04 +01:00
|
|
|
kAudioUnitScope_Input,
|
|
|
|
1,
|
2010-03-13 12:04:29 +01:00
|
|
|
&inputSampleRate,
|
|
|
|
&size );
|
2010-03-11 08:03:04 +01:00
|
|
|
|
2011-03-31 20:25:14 +02:00
|
|
|
if ( static_cast<int> ( inputSampleRate ) != SYSTEM_SAMPLE_RATE_HZ )
|
2010-03-11 08:03:04 +01:00
|
|
|
{
|
2010-03-11 19:33:56 +01:00
|
|
|
throw CGenErr ( QString ( tr ( "Current system audio input device sample "
|
|
|
|
"rate of %1 Hz is not supported. Please open the Audio-MIDI-Setup in "
|
|
|
|
"Applications->Utilities and try to set a sample rate of %2 Hz." ) ).arg (
|
2011-03-31 20:25:14 +02:00
|
|
|
static_cast<int> ( inputSampleRate ) ).arg ( SYSTEM_SAMPLE_RATE_HZ ) );
|
2010-03-11 08:03:04 +01:00
|
|
|
}
|
2010-03-09 20:19:10 +01:00
|
|
|
|
2010-03-13 12:04:29 +01:00
|
|
|
// check output device sample rate
|
2010-03-11 08:03:04 +01:00
|
|
|
size = sizeof ( Float64 );
|
|
|
|
Float64 outputSampleRate;
|
|
|
|
AudioUnitGetProperty ( audioOutputUnit,
|
2010-03-13 12:04:29 +01:00
|
|
|
kAudioUnitProperty_SampleRate,
|
|
|
|
kAudioUnitScope_Output,
|
|
|
|
0,
|
|
|
|
&outputSampleRate,
|
|
|
|
&size );
|
2010-03-11 19:33:56 +01:00
|
|
|
|
2011-03-31 20:25:14 +02:00
|
|
|
if ( static_cast<int> ( outputSampleRate ) != SYSTEM_SAMPLE_RATE_HZ )
|
2010-03-11 08:03:04 +01:00
|
|
|
{
|
2010-03-11 19:33:56 +01:00
|
|
|
throw CGenErr ( QString ( tr ( "Current system audio output device sample "
|
|
|
|
"rate of %1 Hz is not supported. Please open the Audio-MIDI-Setup in "
|
|
|
|
"Applications->Utilities and try to set a sample rate of %2 Hz." ) ).arg (
|
2011-03-31 20:25:14 +02:00
|
|
|
static_cast<int> ( outputSampleRate ) ).arg ( SYSTEM_SAMPLE_RATE_HZ ) );
|
2010-03-11 08:03:04 +01:00
|
|
|
}
|
2010-03-09 20:19:10 +01:00
|
|
|
|
2010-03-11 20:35:19 +01:00
|
|
|
// allocate memory for buffer struct
|
|
|
|
pBufferList = (AudioBufferList*) malloc ( offsetof ( AudioBufferList,
|
|
|
|
mBuffers[0] ) + sizeof ( AudioBuffer ) );
|
2010-03-09 20:19:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void CSound::CloseCoreAudio()
|
|
|
|
{
|
|
|
|
// clean up "gOutputUnit"
|
2010-03-10 22:40:47 +01:00
|
|
|
AudioUnitUninitialize ( audioInputUnit );
|
|
|
|
AudioUnitUninitialize ( audioOutputUnit );
|
2010-03-13 12:04:29 +01:00
|
|
|
CloseComponent ( audioInputUnit );
|
|
|
|
CloseComponent ( audioOutputUnit );
|
2010-03-09 20:19:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void CSound::Start()
|
|
|
|
{
|
2010-03-13 12:04:29 +01:00
|
|
|
// start the rendering
|
|
|
|
AudioOutputUnitStart ( audioInputUnit );
|
|
|
|
AudioOutputUnitStart ( audioOutputUnit );
|
2010-03-09 20:19:10 +01:00
|
|
|
|
|
|
|
// call base class
|
|
|
|
CSoundBase::Start();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CSound::Stop()
|
|
|
|
{
|
|
|
|
// stop the audio stream
|
2010-03-13 12:04:29 +01:00
|
|
|
AudioOutputUnitStop ( audioInputUnit );
|
|
|
|
AudioOutputUnitStop ( audioOutputUnit );
|
2010-03-09 20:19:10 +01:00
|
|
|
|
|
|
|
// call base class
|
|
|
|
CSoundBase::Stop();
|
|
|
|
}
|
|
|
|
|
|
|
|
int CSound::Init ( const int iNewPrefMonoBufferSize )
|
|
|
|
{
|
2010-03-11 20:12:30 +01:00
|
|
|
UInt32 iActualMonoBufferSize;
|
|
|
|
|
2010-03-13 12:04:29 +01:00
|
|
|
// Error message string: in case buffer sizes on input and output cannot be set to the same value
|
|
|
|
const QString strErrBufSize = tr ( "The buffer sizes of the current "
|
|
|
|
"input and output audio device cannot be set to a common value. Please "
|
|
|
|
"choose other input/output audio devices in your system settings." );
|
|
|
|
|
2010-03-11 20:12:30 +01:00
|
|
|
// try to set input buffer size
|
|
|
|
iActualMonoBufferSize =
|
|
|
|
SetBufferSize ( audioInputDevice, true, iNewPrefMonoBufferSize );
|
2010-03-10 22:40:47 +01:00
|
|
|
|
2010-03-11 20:12:30 +01:00
|
|
|
if ( iActualMonoBufferSize != static_cast<UInt32> ( iNewPrefMonoBufferSize ) )
|
|
|
|
{
|
|
|
|
// try to set the input buffer size to the output so that we
|
|
|
|
// have a matching pair
|
2010-03-13 12:04:29 +01:00
|
|
|
if ( SetBufferSize ( audioOutputDevice, false, iActualMonoBufferSize ) !=
|
|
|
|
iActualMonoBufferSize )
|
|
|
|
{
|
|
|
|
throw CGenErr ( strErrBufSize );
|
|
|
|
}
|
2010-03-11 20:12:30 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// try to set output buffer size
|
2010-03-13 12:04:29 +01:00
|
|
|
if ( SetBufferSize ( audioOutputDevice, false, iNewPrefMonoBufferSize ) !=
|
|
|
|
static_cast<UInt32> ( iNewPrefMonoBufferSize ) )
|
|
|
|
{
|
|
|
|
throw CGenErr ( strErrBufSize );
|
|
|
|
}
|
2010-03-11 20:12:30 +01:00
|
|
|
}
|
2010-03-09 20:19:10 +01:00
|
|
|
|
2010-03-10 07:35:49 +01:00
|
|
|
// store buffer size
|
2010-03-11 20:12:30 +01:00
|
|
|
iCoreAudioBufferSizeMono = iActualMonoBufferSize;
|
2010-03-09 20:19:10 +01:00
|
|
|
|
2010-03-10 07:35:49 +01:00
|
|
|
// init base class
|
|
|
|
CSoundBase::Init ( iCoreAudioBufferSizeMono );
|
2010-03-13 12:04:29 +01:00
|
|
|
|
2010-03-10 07:35:49 +01:00
|
|
|
// set internal buffer size value and calculate stereo buffer size
|
|
|
|
iCoreAudioBufferSizeStero = 2 * iCoreAudioBufferSizeMono;
|
2010-03-13 12:04:29 +01:00
|
|
|
|
2010-03-10 07:35:49 +01:00
|
|
|
// create memory for intermediate audio buffer
|
|
|
|
vecsTmpAudioSndCrdStereo.Init ( iCoreAudioBufferSizeStero );
|
2010-03-09 20:19:10 +01:00
|
|
|
|
2010-03-11 20:35:19 +01:00
|
|
|
// fill audio unit buffer struct
|
2010-03-13 12:04:29 +01:00
|
|
|
pBufferList->mNumberBuffers = 1;
|
2010-03-11 20:12:30 +01:00
|
|
|
pBufferList->mBuffers[0].mNumberChannels = 2; // stereo
|
|
|
|
pBufferList->mBuffers[0].mDataByteSize = iCoreAudioBufferSizeMono * 4; // 2 bytes, 2 channels
|
2010-03-13 12:04:29 +01:00
|
|
|
pBufferList->mBuffers[0].mData = &vecsTmpAudioSndCrdStereo[0];
|
2010-03-11 20:35:19 +01:00
|
|
|
|
2010-03-10 07:35:49 +01:00
|
|
|
// initialize unit
|
2010-03-13 12:04:29 +01:00
|
|
|
if ( AudioUnitInitialize ( audioInputUnit ) )
|
2010-03-10 22:40:47 +01:00
|
|
|
{
|
|
|
|
throw CGenErr ( tr ( "Initialization of CoreAudio failed" ) );
|
|
|
|
}
|
|
|
|
|
2010-03-13 12:04:29 +01:00
|
|
|
if ( AudioUnitInitialize ( audioOutputUnit ) )
|
2010-03-05 22:18:11 +01:00
|
|
|
{
|
|
|
|
throw CGenErr ( tr ( "Initialization of CoreAudio failed" ) );
|
|
|
|
}
|
2010-03-05 21:19:12 +01:00
|
|
|
|
2010-03-10 07:35:49 +01:00
|
|
|
return iCoreAudioBufferSizeMono;
|
2010-03-05 21:19:12 +01:00
|
|
|
}
|
|
|
|
|
2010-03-11 20:12:30 +01:00
|
|
|
UInt32 CSound::SetBufferSize ( AudioDeviceID& audioDeviceID,
|
|
|
|
const bool bIsInput,
|
|
|
|
UInt32 iPrefBufferSize )
|
|
|
|
{
|
|
|
|
// first set the value
|
|
|
|
UInt32 iSizeBufValue = sizeof ( UInt32 );
|
|
|
|
AudioDeviceSetProperty ( audioDeviceID,
|
|
|
|
NULL,
|
|
|
|
0,
|
|
|
|
bIsInput,
|
|
|
|
kAudioDevicePropertyBufferFrameSize,
|
|
|
|
iSizeBufValue,
|
|
|
|
&iPrefBufferSize );
|
|
|
|
|
|
|
|
// read back which value is actually used
|
|
|
|
UInt32 iActualMonoBufferSize;
|
|
|
|
AudioDeviceGetProperty ( audioDeviceID,
|
|
|
|
0,
|
|
|
|
bIsInput,
|
|
|
|
kAudioDevicePropertyBufferFrameSize,
|
|
|
|
&iSizeBufValue,
|
|
|
|
&iActualMonoBufferSize );
|
|
|
|
|
|
|
|
return iActualMonoBufferSize;
|
|
|
|
}
|
|
|
|
|
2010-03-10 22:40:47 +01:00
|
|
|
OSStatus CSound::processInput ( void* inRefCon,
|
|
|
|
AudioUnitRenderActionFlags* ioActionFlags,
|
|
|
|
const AudioTimeStamp* inTimeStamp,
|
|
|
|
UInt32 inBusNumber,
|
|
|
|
UInt32 inNumberFrames,
|
2010-03-13 10:46:51 +01:00
|
|
|
AudioBufferList* )
|
2010-03-05 21:19:12 +01:00
|
|
|
{
|
|
|
|
CSound* pSound = reinterpret_cast<CSound*> ( inRefCon );
|
2010-03-11 20:35:19 +01:00
|
|
|
|
2010-03-11 20:12:30 +01:00
|
|
|
QMutexLocker locker ( &pSound->Mutex );
|
|
|
|
|
2010-03-09 20:19:10 +01:00
|
|
|
// get the new audio data
|
2010-03-13 10:46:51 +01:00
|
|
|
AudioUnitRender ( pSound->audioInputUnit,
|
|
|
|
ioActionFlags,
|
|
|
|
inTimeStamp,
|
|
|
|
inBusNumber,
|
|
|
|
inNumberFrames,
|
|
|
|
pSound->pBufferList );
|
2010-03-09 21:36:35 +01:00
|
|
|
|
2010-03-10 22:40:47 +01:00
|
|
|
// call processing callback function
|
|
|
|
pSound->ProcessCallback ( pSound->vecsTmpAudioSndCrdStereo );
|
2010-03-09 20:19:10 +01:00
|
|
|
|
2010-03-10 22:40:47 +01:00
|
|
|
return noErr;
|
2010-03-09 20:19:10 +01:00
|
|
|
}
|
|
|
|
|
2010-03-13 12:04:29 +01:00
|
|
|
OSStatus CSound::processOutput ( void* inRefCon,
|
2010-03-13 10:46:51 +01:00
|
|
|
AudioUnitRenderActionFlags*,
|
|
|
|
const AudioTimeStamp*,
|
|
|
|
UInt32,
|
|
|
|
UInt32,
|
2010-03-13 12:04:29 +01:00
|
|
|
AudioBufferList* ioData )
|
2010-03-10 22:40:47 +01:00
|
|
|
{
|
|
|
|
CSound* pSound = reinterpret_cast<CSound*> ( inRefCon );
|
2010-03-05 21:19:12 +01:00
|
|
|
|
2010-03-11 20:12:30 +01:00
|
|
|
QMutexLocker locker ( &pSound->Mutex );
|
|
|
|
|
|
|
|
memcpy ( ioData->mBuffers[0].mData,
|
2010-03-13 12:04:29 +01:00
|
|
|
&pSound->vecsTmpAudioSndCrdStereo[0],
|
|
|
|
pSound->pBufferList->mBuffers[0].mDataByteSize);
|
2010-03-05 21:19:12 +01:00
|
|
|
|
|
|
|
return noErr;
|
|
|
|
}
|