Commit b604a31e authored by Raymond Toy's avatar Raymond Toy Committed by Commit Bot

Add pending activity to keep Webaudio media nodes alive

MediaStreamSourceNode and related nodes should report they have
activity whenever the context is running, because they actually do.
This prevents the nodes from getting prematurely collected.
Unfortunately, this also means nodes will not be collected until the
context is suspended or stopped.



Bug: 937231
Change-Id: I4cd93fe757d8f34fbbc0c68aeaace4727c77be14
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1496541Reviewed-by: default avatarHongchan Choi <hongchan@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Commit-Queue: Raymond Toy <rtoy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#638306}
parent 315120d5
...@@ -193,4 +193,9 @@ void MediaStreamAudioSourceNode::SetFormat(uint32_t number_of_channels, ...@@ -193,4 +193,9 @@ void MediaStreamAudioSourceNode::SetFormat(uint32_t number_of_channels,
source_sample_rate); source_sample_rate);
} }
bool MediaStreamAudioSourceNode::HasPendingActivity() const {
// As long as the context is running, this node has activity.
return (context()->ContextState() == BaseAudioContext::kRunning);
}
} // namespace blink } // namespace blink
...@@ -77,8 +77,10 @@ class MediaStreamAudioSourceHandler final : public AudioHandler { ...@@ -77,8 +77,10 @@ class MediaStreamAudioSourceHandler final : public AudioHandler {
unsigned source_number_of_channels_; unsigned source_number_of_channels_;
}; };
class MediaStreamAudioSourceNode final : public AudioNode, class MediaStreamAudioSourceNode final
public AudioSourceProviderClient { : public AudioNode,
public AudioSourceProviderClient,
public ActiveScriptWrappable<MediaStreamAudioSourceNode> {
DEFINE_WRAPPERTYPEINFO(); DEFINE_WRAPPERTYPEINFO();
USING_GARBAGE_COLLECTED_MIXIN(MediaStreamAudioSourceNode); USING_GARBAGE_COLLECTED_MIXIN(MediaStreamAudioSourceNode);
...@@ -101,6 +103,8 @@ class MediaStreamAudioSourceNode final : public AudioNode, ...@@ -101,6 +103,8 @@ class MediaStreamAudioSourceNode final : public AudioNode,
// AudioSourceProviderClient functions: // AudioSourceProviderClient functions:
void SetFormat(uint32_t number_of_channels, float sample_rate) override; void SetFormat(uint32_t number_of_channels, float sample_rate) override;
bool HasPendingActivity() const final;
private: private:
MediaStreamAudioSourceHandler& GetMediaStreamAudioSourceHandler() const; MediaStreamAudioSourceHandler& GetMediaStreamAudioSourceHandler() const;
......
...@@ -27,7 +27,8 @@ ...@@ -27,7 +27,8 @@
[ [
Constructor(AudioContext context, MediaStreamAudioSourceOptions options), Constructor(AudioContext context, MediaStreamAudioSourceOptions options),
RaisesException=Constructor, RaisesException=Constructor,
Measure Measure,
ActiveScriptWrappable
] ]
interface MediaStreamAudioSourceNode : AudioNode { interface MediaStreamAudioSourceNode : AudioNode {
[SameObject, ImplementedAs=getMediaStream] readonly attribute MediaStream mediaStream; [SameObject, ImplementedAs=getMediaStream] readonly attribute MediaStream mediaStream;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment