AudioThumbnail bug?


#1

Consider the call to draw the thumbnail:

If x is 0, it works ok. If x > 0 then drawChannel draws garbage to the left of x. If x is large enough (but still smaller than w), it throws an access violation because of a bad pointer.

I traced inside of drawChannel and found the following the lines:

const Rectangle clip (g.getClipBounds()); const int skipLeft = clip.getX() - x; w -= skipLeft; x += skipLeft;
In my code, clip.getX() always returns 0, so that if x > 0, skipLeft < 0. This decrements x which causes the waveform to be drawn outside the specified bounds, presumably from bogus data. It also increments w, which I believe will cause the access violation as w is used to control what gets cached in the thumbnail. A value of w > than the original width passed in will cause the cache to read from outside of the inputSource’s data range.

Again, it all works fine if x, the first argument to drawChannel, is 0.

Any insight on this would be greatly appreciated – Jeff.


#2

Hmm. Yes, that’s definitely a ropey bit of code. I think what I should have written is:

const int skipLeft = jlimit (0, w, clip.getX() - x);


#3

ahh yes, we had problems with this as well but never found out why exactly it gave access violations.