bug 1391482 add a method to create an AudioBuffer from AudioChunk data r=padenot

MozReview-Commit-ID: GkJJo6UW4gl

--HG--
extra : rebase_source : 457919cd769d20f193c64140f7b63fb08e715949
This commit is contained in:
Karl Tomlinson 2017-08-16 17:45:48 +12:00
Родитель 1cd9d48de3
Коммит 1225650a7f
2 изменённых файлов: 22 добавлений и 0 удалений

Просмотреть файл

@ -248,6 +248,23 @@ AudioBuffer::Create(nsPIDOMWindowInner* aWindow, uint32_t aNumberOfChannels,
return buffer.forget();
}
/* static */ already_AddRefed<AudioBuffer>
AudioBuffer::Create(nsPIDOMWindowInner* aWindow, float aSampleRate,
AudioChunk&& aInitialContents)
{
AudioChunk initialContents = aInitialContents;
ErrorResult rv;
RefPtr<AudioBuffer> buffer =
new AudioBuffer(aWindow, initialContents.ChannelCount(),
initialContents.mDuration, aSampleRate, rv);
if (rv.Failed()) {
return nullptr;
}
buffer->mSharedChannels = Move(aInitialContents);
return buffer.forget();
}
JSObject*
AudioBuffer::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
{

Просмотреть файл

@ -54,6 +54,11 @@ public:
nullptr, aRv);
}
// Non-unit AudioChunk::mVolume is not supported
static already_AddRefed<AudioBuffer>
Create(nsPIDOMWindowInner* aWindow, float aSampleRate,
AudioChunk&& aInitialContents);
size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(AudioBuffer)