mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1078451 - Accept a free function in ThreadSharedFloatArrayBufferList::SetData. r=jesup
This commit is contained in:
parent
5d68c19c22
commit
c4810bf94e
@ -226,7 +226,7 @@ StealJSArrayDataIntoThreadSharedFloatArrayBufferList(JSContext* aJSContext,
|
|||||||
? (uint8_t*) JS_StealArrayBufferContents(aJSContext, arrayBuffer)
|
? (uint8_t*) JS_StealArrayBufferContents(aJSContext, arrayBuffer)
|
||||||
: nullptr;
|
: nullptr;
|
||||||
if (stolenData) {
|
if (stolenData) {
|
||||||
result->SetData(i, stolenData, reinterpret_cast<float*>(stolenData));
|
result->SetData(i, stolenData, js_free, reinterpret_cast<float*>(stolenData));
|
||||||
} else {
|
} else {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
@ -38,12 +38,16 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct Storage {
|
struct Storage {
|
||||||
Storage()
|
Storage() :
|
||||||
{
|
mDataToFree(nullptr),
|
||||||
mDataToFree = nullptr;
|
mFree(nullptr),
|
||||||
mSampleData = nullptr;
|
mSampleData(nullptr)
|
||||||
|
{}
|
||||||
|
~Storage() {
|
||||||
|
if (mFree) {
|
||||||
|
mFree(mDataToFree);
|
||||||
|
} else { MOZ_ASSERT(!mDataToFree); }
|
||||||
}
|
}
|
||||||
~Storage() { free(mDataToFree); }
|
|
||||||
size_t SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const
|
size_t SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const
|
||||||
{
|
{
|
||||||
// NB: mSampleData might not be owned, if it is it just points to
|
// NB: mSampleData might not be owned, if it is it just points to
|
||||||
@ -51,6 +55,7 @@ public:
|
|||||||
return aMallocSizeOf(mDataToFree);
|
return aMallocSizeOf(mDataToFree);
|
||||||
}
|
}
|
||||||
void* mDataToFree;
|
void* mDataToFree;
|
||||||
|
void (*mFree)(void*);
|
||||||
const float* mSampleData;
|
const float* mSampleData;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -67,11 +72,17 @@ public:
|
|||||||
* Call this only during initialization, before the object is handed to
|
* Call this only during initialization, before the object is handed to
|
||||||
* any other thread.
|
* any other thread.
|
||||||
*/
|
*/
|
||||||
void SetData(uint32_t aIndex, void* aDataToFree, const float* aData)
|
void SetData(uint32_t aIndex, void* aDataToFree, void (*aFreeFunc)(void*), const float* aData)
|
||||||
{
|
{
|
||||||
Storage* s = &mContents[aIndex];
|
Storage* s = &mContents[aIndex];
|
||||||
free(s->mDataToFree);
|
if (s->mFree) {
|
||||||
|
s->mFree(s->mDataToFree);
|
||||||
|
} else {
|
||||||
|
MOZ_ASSERT(!s->mDataToFree);
|
||||||
|
}
|
||||||
|
|
||||||
s->mDataToFree = aDataToFree;
|
s->mDataToFree = aDataToFree;
|
||||||
|
s->mFree = aFreeFunc;
|
||||||
s->mSampleData = aData;
|
s->mSampleData = aData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -258,7 +258,7 @@ ConvolverNode::SetBuffer(JSContext* aCx, AudioBuffer* aBuffer, ErrorResult& aRv)
|
|||||||
for (uint32_t i = 0; i < data->GetChannels(); ++i) {
|
for (uint32_t i = 0; i < data->GetChannels(); ++i) {
|
||||||
PodCopy(channelData + length * i, data->GetData(i), mBuffer->Length());
|
PodCopy(channelData + length * i, data->GetData(i), mBuffer->Length());
|
||||||
PodZero(channelData + length * i + mBuffer->Length(), WEBAUDIO_BLOCK_SIZE - mBuffer->Length());
|
PodZero(channelData + length * i + mBuffer->Length(), WEBAUDIO_BLOCK_SIZE - mBuffer->Length());
|
||||||
paddedBuffer->SetData(i, (i == 0) ? channelData : nullptr, channelData);
|
paddedBuffer->SetData(i, (i == 0) ? channelData : nullptr, free, channelData);
|
||||||
}
|
}
|
||||||
data = paddedBuffer;
|
data = paddedBuffer;
|
||||||
}
|
}
|
||||||
|
@ -38,9 +38,9 @@ PeriodicWave::PeriodicWave(AudioContext* aContext,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
PodCopy(buffer, aRealData, aLength);
|
PodCopy(buffer, aRealData, aLength);
|
||||||
mCoefficients->SetData(0, buffer, buffer);
|
mCoefficients->SetData(0, buffer, free, buffer);
|
||||||
PodCopy(buffer+aLength, aImagData, aLength);
|
PodCopy(buffer+aLength, aImagData, aLength);
|
||||||
mCoefficients->SetData(1, nullptr, buffer+aLength);
|
mCoefficients->SetData(1, nullptr, free, buffer+aLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t
|
size_t
|
||||||
|
Loading…
Reference in New Issue
Block a user