MeteringView exc_bad_access
MeteringView exc_bad_access
- Subject: MeteringView exc_bad_access
- From: Graeme MacDonald <email@hidden>
- Date: Wed, 3 Nov 2010 14:30:49 -0500
Hi, I have dropped the MeteringView code from MatrixMixerTest into my own application and am continually getting EXC_BAD_ACCESS. Before that occurs, the meter does respond to audio, but never draws correctly. When I run it within MatrixMixerTest, all appears to be well.
I'm guessing it's some sort of memory problem (I am no expert) and I've been trying to hunt down the problem. While looking at the code in MatrixMixerTest I'm confused by the following.
In doTimer, this code is used (note 2 floats):
float amps[2];
err = AudioUnitGetParameter(mixer, kMatrixMixerParam_PostAveragePower, kAudioUnitScope_Input, i, &s[0]);
err = AudioUnitGetParameter(mixer, kMatrixMixerParam_PostPeakHoldLevel, kAudioUnitScope_Input, i, &s[1]);
value = sqrt(dbamp(value));
[meter[i] updateMeters: amps];
however, in the MeteringView class, in updateMeters, the code uses sizeof to get the number to iterate with. This returns 4 and as such meterValues has indices 0-3 applied against it. If the passed in array only has 2 floats in it, how can this work?
Thanks.
- (void) updateMeters: (float *) meterValues {
if (![self inLiveResize]) {
int numItems = sizeof(meterValues);
for (int i = 0; i < numItems; i++) {
float tempValue = dbamp(meterValues[i]);
mOldMeterValues[i] = mMeterValues[i];
float pixelValue = [self pixelForValue: tempValue inSize: (int) [self bounds].size.height];
float top = [self bounds].size.height - (mHasClip ? kClipBoxHeight + 4: 2);
if (pixelValue < 0)
pixelValue = 0;
else if (pixelValue > top)
pixelValue = top;
mMeterValues[i] = pixelValue;
if (mHasClip) {
if (tempValue > mMaxValue)
mClipValues[i] = 1;
}
}
drawsMetersOnly = YES;
[self setNeedsDisplay: YES];
}
}
_______________________________________________
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