зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1388236 - Remove B2G-only AudioChannel code from WebAudio. r=padenot
This commit is contained in:
Родитель
2f8cc7804c
Коммит
f50f2d9e15
|
@ -328,7 +328,6 @@ AudioDestinationNode::AudioDestinationNode(AudioContext* aContext,
|
|||
: AudioNode(aContext, aIsOffline ? aNumberOfChannels : 2,
|
||||
ChannelCountMode::Explicit, ChannelInterpretation::Speakers)
|
||||
, mFramesToProduce(aLength)
|
||||
, mAudioChannel(AudioChannel::Normal)
|
||||
, mIsOffline(aIsOffline)
|
||||
, mAudioChannelSuspended(false)
|
||||
, mCaptured(false)
|
||||
|
@ -591,65 +590,6 @@ AudioDestinationNode::WindowAudioCaptureChanged(bool aCapture)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
AudioChannel
|
||||
AudioDestinationNode::MozAudioChannelType() const
|
||||
{
|
||||
return mAudioChannel;
|
||||
}
|
||||
|
||||
void
|
||||
AudioDestinationNode::SetMozAudioChannelType(AudioChannel aValue, ErrorResult& aRv)
|
||||
{
|
||||
if (Context()->IsOffline()) {
|
||||
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
|
||||
return;
|
||||
}
|
||||
|
||||
if (aValue != mAudioChannel &&
|
||||
CheckAudioChannelPermissions(aValue)) {
|
||||
mAudioChannel = aValue;
|
||||
|
||||
if (mAudioChannelAgent) {
|
||||
CreateAudioChannelAgent();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
AudioDestinationNode::CheckAudioChannelPermissions(AudioChannel aValue)
|
||||
{
|
||||
// Only normal channel doesn't need permission.
|
||||
if (aValue == AudioChannel::Normal) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Maybe this audio channel is equal to the default one.
|
||||
if (aValue == AudioChannelService::GetDefaultAudioChannel()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIPermissionManager> permissionManager =
|
||||
services::GetPermissionManager();
|
||||
if (!permissionManager) {
|
||||
return false;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIScriptObjectPrincipal> sop = do_QueryInterface(GetOwner());
|
||||
NS_ASSERTION(sop, "Window didn't QI to nsIScriptObjectPrincipal!");
|
||||
nsCOMPtr<nsIPrincipal> principal = sop->GetPrincipal();
|
||||
|
||||
uint32_t perm = nsIPermissionManager::UNKNOWN_ACTION;
|
||||
|
||||
nsCString channel;
|
||||
channel.AssignASCII(AudioChannelValues::strings[uint32_t(aValue)].value,
|
||||
AudioChannelValues::strings[uint32_t(aValue)].length);
|
||||
permissionManager->TestExactPermissionFromPrincipal(principal,
|
||||
nsCString(NS_LITERAL_CSTRING("audio-channel-") + channel).get(),
|
||||
&perm);
|
||||
|
||||
return perm == nsIPermissionManager::ALLOW_ACTION;
|
||||
}
|
||||
|
||||
nsresult
|
||||
AudioDestinationNode::CreateAudioChannelAgent()
|
||||
{
|
||||
|
@ -667,7 +607,7 @@ AudioDestinationNode::CreateAudioChannelAgent()
|
|||
|
||||
mAudioChannelAgent = new AudioChannelAgent();
|
||||
rv = mAudioChannelAgent->InitWithWeakCallback(GetOwner(),
|
||||
static_cast<int32_t>(mAudioChannel),
|
||||
static_cast<int32_t>(AudioChannel::Normal),
|
||||
this);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
|
|
|
@ -59,8 +59,6 @@ public:
|
|||
|
||||
void OfflineShutdown();
|
||||
|
||||
AudioChannel MozAudioChannelType() const;
|
||||
|
||||
void NotifyMainThreadStreamFinished() override;
|
||||
void FireOfflineCompletionEvent();
|
||||
|
||||
|
@ -88,9 +86,6 @@ protected:
|
|||
virtual ~AudioDestinationNode();
|
||||
|
||||
private:
|
||||
void SetMozAudioChannelType(AudioChannel aValue, ErrorResult& aRv);
|
||||
bool CheckAudioChannelPermissions(AudioChannel aValue);
|
||||
|
||||
SelfReference<AudioDestinationNode> mOfflineRenderingRef;
|
||||
uint32_t mFramesToProduce;
|
||||
|
||||
|
@ -99,8 +94,6 @@ private:
|
|||
|
||||
RefPtr<Promise> mOfflineRenderingPromise;
|
||||
|
||||
// Audio Channel Type.
|
||||
AudioChannel mAudioChannel;
|
||||
bool mIsOffline;
|
||||
bool mAudioChannelSuspended;
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче