forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Synchronize AudioWorkletProcessor information upon script evaluation
Spec: https://webaudio.github.io/web-audio-api/#dfn-node-name-to-parameter-descriptor-map Upon the evaluation of script in AudioWorkletGlobalScope, the associated AudioWokrletMessagingProxy (which is associated with a BaseAudioContext) needs to be updated with the data from the script. Bug: 755566 Change-Id: I9013adf67710b9d8cf932efc94be27116727dd95 Reviewed-on: https://chromium-review.googlesource.com/622067 Reviewed-by: Raymond Toy <rtoy@chromium.org> Reviewed-by: Hiroki Nakagawa <nhiroki@chromium.org> Commit-Queue: Hongchan Choi <hongchan@chromium.org> Cr-Commit-Position: refs/heads/master@{#498664}
- Loading branch information
Showing
8 changed files
with
159 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
third_party/WebKit/Source/modules/webaudio/CrossThreadAudioWorkletProcessorInfo.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
// Copyright 2017 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#ifndef CrossThreadAudioWorkletProcessorInfo_h | ||
#define CrossThreadAudioWorkletProcessorInfo_h | ||
|
||
#include "modules/webaudio/AudioParamDescriptor.h" | ||
#include "modules/webaudio/AudioWorkletProcessorDefinition.h" | ||
|
||
namespace blink { | ||
|
||
// A class for shallow repackage of |AudioParamDescriptor|. This is created only | ||
// when requested when the synchronization between AudioWorkletMessagingProxy | ||
// and AudioWorkletGlobalScope. | ||
class CrossThreadAudioParamInfo { | ||
DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); | ||
|
||
public: | ||
explicit CrossThreadAudioParamInfo(const AudioParamDescriptor* descriptor) | ||
: name_(descriptor->name().IsolatedCopy()), | ||
default_value_(descriptor->defaultValue()), | ||
max_value_(descriptor->maxValue()), | ||
min_value_(descriptor->minValue()) {} | ||
|
||
const String& Name() const { return name_; } | ||
float DefaultValue() const { return default_value_; } | ||
float MaxValue() const { return max_value_; } | ||
float MinValue() const { return min_value_; } | ||
|
||
private: | ||
const String name_; | ||
const float default_value_; | ||
const float max_value_; | ||
const float min_value_; | ||
}; | ||
|
||
// A class for shallow repackage of |AudioWorkletProcessorDefinition|. This is | ||
// created only when requested when the synchronization between | ||
// AudioWorkletMessagingProxy and AudioWorkletGlobalScope. | ||
class CrossThreadAudioWorkletProcessorInfo { | ||
DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); | ||
|
||
public: | ||
explicit CrossThreadAudioWorkletProcessorInfo( | ||
const AudioWorkletProcessorDefinition& definition) | ||
: name_(definition.GetName().IsolatedCopy()) { | ||
// To avoid unnecessary reallocations of the vector. | ||
param_info_list_.ReserveInitialCapacity( | ||
definition.GetAudioParamDescriptorNames().size()); | ||
|
||
for (const String& name : definition.GetAudioParamDescriptorNames()) { | ||
param_info_list_.emplace_back( | ||
definition.GetAudioParamDescriptor(name)); | ||
} | ||
} | ||
|
||
const String& Name() const { return name_; } | ||
Vector<CrossThreadAudioParamInfo> ParamInfoList() { return param_info_list_; } | ||
|
||
private: | ||
const String name_; | ||
Vector<CrossThreadAudioParamInfo> param_info_list_; | ||
}; | ||
|
||
} // namespace blink | ||
|
||
#endif // CrossThreadAudioWorkletProcessorInfo_h |