Fix theoretical race using TrackBase::sampleRate()

In two places we assumed that TrackBase::sampleRate() would return the
same value when it is called twice in the same function.  This is not
guaranteed; sampleRate() reads from the control block so the return
value could change.  To fix this, only call sampleRate() once and cache
the return value to get a consistent value.

This was only a theoretical race.  In MixerThread::prepareTracks_l()
it would have no bad effect.  In TimedTrack::getNextBuffer() it could
cause a real problem, but we don't currently support dynamic sample rate
ratios for timed tracks.

Change-Id: I8e5c33f0121fc058d1e70c2ab5e9135397d3e0b7
2 files changed