Output to device problem using AudioConverter
Output to device problem using AudioConverter
- Subject: Output to device problem using AudioConverter
- From: Malcolm Haylock <email@hidden>
- Date: Mon, 13 Sep 2004 17:31:32 +0100
Hi All,
I'm having trouble with output to a couple of audio devices. Output
to Apple devices works fine.
The code I'm using is shown below.
Basically I'm setting up an AudioConverter to go from my custom input
stream (AudioStreamBasicDescription sourceFormat) to the device
described by AudioStreamBasicDescription destinationFormat.
I'm trying first to open with 8 outs. If this fails I try 6 then 4
then 2. For built-in audio this opens with 2 and plays fine. For a
couple of devices it opens in mono and is sometimes distorted (as
reported by users - I can't test this in more detail). Some of my
code is wwrapped in a custom object (CCoreAudio::gHAL) but this does
basic calls. The problem is more with my methodology. Any ideas?
gHAL.GetFormat(&destinationFormat);
AudioStreamBasicDescription destinationFormatSave=destinationFormat;
// we know sample rate is supported as we tested this earlier
destinationFormat.mSampleRate = sourceFormat.mSampleRate;
//try successively less pairs of outs
for(int iPairs=4; iPairs>=1; iPairs--){
CCoreAudio::SetFormatChannels(&destinationFormat, 2*iPairs);
myErr=gHAL.SetFormat(&destinationFormat);
if(myErr==noErr)
break;
}
// use default if no luck
if(myErr!=noErr){
destinationFormat=destinationFormatSave;
myErr=gHAL.SetFormat(&destinationFormat);
}
if(myErr!=noErr)
CError::DoError("\pError setting device format",myErr);
else{
// create our converter
myErr = AudioConverterNew(&sourceFormat, &destinationFormat,
&theAudioConverter);
Thanks,
Malcolm
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden