bug 1203380 tighten not-sharing assertion in ChannelFloatsForWrite() r=padenot

--HG--
extra : rebase_source : 5206ae1ae59bade7f2b40400e0f851bf26df5d9c
This commit is contained in:
Karl Tomlinson 2015-09-10 09:01:55 +12:00
parent 4935533d54
commit 99d66c32cb
2 changed files with 12 additions and 7 deletions

View File

@ -124,9 +124,12 @@ AudioBlock::ClearDownstreamMark() {
}
}
void
AudioBlock::AssertNoLastingShares() {
MOZ_ASSERT(!mBuffer->AsAudioBlockBuffer()->HasLastingShares());
bool
AudioBlock::CanWrite() {
// If mBufferIsDownstreamRef is set then the buffer is not ours to use.
// It may be in use by another node which is not downstream.
return !mBufferIsDownstreamRef &&
!mBuffer->AsAudioBlockBuffer()->HasLastingShares();
}
void

View File

@ -54,12 +54,14 @@ public:
*/
void AllocateChannels(uint32_t aChannelCount);
/**
* ChannelFloatsForWrite() should only be used when the buffers have been
* created with AllocateChannels().
*/
float* ChannelFloatsForWrite(size_t aChannel)
{
MOZ_ASSERT(mBufferFormat == AUDIO_FORMAT_FLOAT32);
#if DEBUG
AssertNoLastingShares();
#endif
MOZ_ASSERT(CanWrite());
return static_cast<float*>(const_cast<void*>(mChannelData[aChannel]));
}
@ -103,7 +105,7 @@ public:
private:
void ClearDownstreamMark();
void AssertNoLastingShares();
bool CanWrite();
// mBufferIsDownstreamRef is set only when mBuffer references an
// AudioBlockBuffer created in a different AudioBlock. That can happen when