Re: AU Parameter confusion on PPC
Re: AU Parameter confusion on PPC
- Subject: Re: AU Parameter confusion on PPC
- From: Chris <email@hidden>
- Date: Thu, 06 Sep 2007 08:44:51 +0200
Hi,
below is the changes I made in AUScopeElement.cpp to correct that problem for me.
basically, in optimization mode (for mUseIndexedParameters only in save), as
entry.value = EndianU32_NtoB(*(UInt32 *)&v );
is not working due to alignment problems (different alignments in optimized mode for float and
uint32, so = will never work it seams)
so, instead of =, I do memmove, which don't care about alignment.
Regards
Chris
void AUElement::SaveState(CFMutableDataRef data)
{
if(mUseIndexedParameters)
{//printf("AUElement::SaveState mUseIndexedParameters\n");
UInt32 nparams = mIndexedParameters.size();
UInt32 theData = EndianU32_NtoB(nparams);
CFDataAppendBytes(data, (UInt8 *)&theData, sizeof(nparams));
for (UInt32 i = 0; i < nparams; i++)
{
struct {
UInt32 paramID;
//CFSwappedFloat32 value; crashes gcc3 PFE
UInt32 value; // really a big-endian float
} entry;
entry.paramID = EndianU32_NtoB(i);
Float32 v = mIndexedParameters[i].GetValue();
UInt32 pini;
memmove((void*)(&pini),(void*)(&v),sizeof(UInt32));
entry.value = EndianU32_NtoB(pini );
//entry.value = EndianU32_NtoB(*(UInt32 *)&v );
//printf(" append %ld->%ld (i=%ld ->v=%f pini=%ld
&pini=%p)\n",entry.paramID,entry.value,i,v,pini,&pini);
CFDataAppendBytes(data, (UInt8 *)&entry, sizeof(entry));
}
}
else
{//printf("AUElement::SaveState not mUseIndexedParameters\n");
UInt32 nparams = EndianU32_NtoB(mParameters.size());
CFDataAppendBytes(data, (UInt8 *)&nparams, sizeof(nparams));
for (ParameterMap::iterator i = mParameters.begin(); i != mParameters.end(); ++i) {
struct {
UInt32 paramID;
//CFSwappedFloat32 value; crashes gcc3 PFE
UInt32 value; // really a big-endian float
} entry;
entry.paramID = EndianU32_NtoB((*i).first);
Float32 v = (*i).second.GetValue();
entry.value = EndianU32_NtoB(*(UInt32 *)&v );
//UInt32 pini;
//memmove((void*)(&pini),(void*)(&v),sizeof(UInt32));
//entry.value = EndianU32_NtoB(pini );
//printf(" append %ld->%ld ( ->v=%f pini=%ld &pini=%p)\n",entry.paramID,entry.value,v,pini,&pini);
CFDataAppendBytes(data, (UInt8 *)&entry, sizeof(entry));
}
}
//printf("Saved state=\n"); CFShow(data);
}
//_____________________________________________________________________________
//
const UInt8 * AUElement::RestoreState(const UInt8 *state)
{
const UInt8 *p = state;
UInt32 nparams = EndianU32_BtoN(*(UInt32 *)p);
p += sizeof(UInt32);
for (UInt32 i = 0; i < nparams; ++i) {
struct {
UInt32 paramID;
Float32 value;
} entry;
entry.paramID = EndianU32_BtoN(*(UInt32 *)p);
p += sizeof(UInt32);
UInt32 temp = EndianU32_BtoN(*(UInt32 *)p);
//entry.value = *(Float32 *)&temp;
Float32 pini;
memmove((void*)(&pini),(void*)(&temp),sizeof(Float32));
entry.value = pini;
//printf("AUElement::RestoreState SetParameter %ld->%f (temp=%ld
pini=%f)\n",entry.paramID,entry.value,temp,pini);
p += sizeof(Float32);
SetParameter(entry.paramID, entry.value);
}
return p;
}
_______________________________________________
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