зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1387454 - Set sample rate in AudioContext constructor. r=padenot
MozReview-Commit-ID: 9uQLotrF86k --HG-- extra : rebase_source : df35ed5401e24addb2374e3dd2921963e8fe7aa7
This commit is contained in:
Родитель
ee0b8e9fc2
Коммит
5c2b9f6591
|
@ -120,7 +120,7 @@ NS_INTERFACE_MAP_END_INHERITING(DOMEventTargetHelper)
|
|||
|
||||
static float GetSampleRateForAudioContext(bool aIsOffline, float aSampleRate)
|
||||
{
|
||||
if (aIsOffline) {
|
||||
if (aIsOffline || aSampleRate != 0.0) {
|
||||
return aSampleRate;
|
||||
} else {
|
||||
return static_cast<float>(CubebUtils::PreferredSampleRate());
|
||||
|
@ -197,6 +197,7 @@ AudioContext::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
|
|||
|
||||
/* static */ already_AddRefed<AudioContext>
|
||||
AudioContext::Constructor(const GlobalObject& aGlobal,
|
||||
const AudioContextOptions& aOptions,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
nsCOMPtr<nsPIDOMWindowInner> window = do_QueryInterface(aGlobal.GetAsSupports());
|
||||
|
@ -205,10 +206,18 @@ AudioContext::Constructor(const GlobalObject& aGlobal,
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
if (aOptions.mSampleRate > 0 &&
|
||||
(aOptions.mSampleRate - WebAudioUtils::MinSampleRate < 0.0 ||
|
||||
WebAudioUtils::MaxSampleRate - aOptions.mSampleRate < 0.0)) {
|
||||
aRv.Throw(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
uint32_t maxChannelCount = std::min<uint32_t>(WebAudioUtils::MaxChannelCount,
|
||||
CubebUtils::MaxNumberOfChannels());
|
||||
RefPtr<AudioContext> object =
|
||||
new AudioContext(window, false,maxChannelCount);
|
||||
new AudioContext(window, false, maxChannelCount,
|
||||
0, aOptions.mSampleRate);
|
||||
aRv = object->Init();
|
||||
if (NS_WARN_IF(aRv.Failed())) {
|
||||
return nullptr;
|
||||
|
|
|
@ -116,6 +116,7 @@ private:
|
|||
};
|
||||
|
||||
enum class AudioContextOperation { Suspend, Resume, Close };
|
||||
struct AudioContextOptions;
|
||||
|
||||
class AudioContext final : public DOMEventTargetHelper,
|
||||
public nsIMemoryReporter,
|
||||
|
@ -153,7 +154,9 @@ public:
|
|||
|
||||
// Constructor for regular AudioContext
|
||||
static already_AddRefed<AudioContext>
|
||||
Constructor(const GlobalObject& aGlobal, ErrorResult& aRv);
|
||||
Constructor(const GlobalObject& aGlobal,
|
||||
const AudioContextOptions& aOptions,
|
||||
ErrorResult& aRv);
|
||||
|
||||
// Constructor for offline AudioContext with options object
|
||||
static already_AddRefed<AudioContext>
|
||||
|
|
Загрузка…
Ссылка в новой задаче