Commit bb9b04fe authored by sigbjornf's avatar sigbjornf Committed by Commit bot

Pull AudioDestinationConsumer off the Blink GC heap.

The AudioDestinationConsumer interface and its single implementation
does not meet the bar for being on the Blink GC heap. It doesn't cause
harm to have them there, but in order to diagnose an unexplained
failure, pull these objects off the heap.

We may want to restore them to the Blink GC heap once the issue has
been resolved.

R=
BUG=682945

Review-Url: https://codereview.chromium.org/2748133003
Cr-Commit-Position: refs/heads/master@{#456736}
parent 09165f0b
......@@ -31,20 +31,17 @@
#ifndef AudioDestinationConsumer_h
#define AudioDestinationConsumer_h
#include <memory>
#include "platform/PlatformExport.h"
#include "platform/heap/Handle.h"
namespace blink {
class AudioBus;
class PLATFORM_EXPORT AudioDestinationConsumer
: public GarbageCollected<AudioDestinationConsumer> {
class PLATFORM_EXPORT AudioDestinationConsumer {
public:
virtual void setFormat(size_t numberOfChannels, float sampleRate) = 0;
virtual void consumeAudio(AudioBus*, size_t numberOfFrames) = 0;
DEFINE_INLINE_VIRTUAL_TRACE() {}
};
} // namespace blink
......
......@@ -148,6 +148,8 @@ bool WebMediaStreamSource::requiresAudioConsumer() const {
}
class ConsumerWrapper final : public AudioDestinationConsumer {
USING_FAST_MALLOC(ConsumerWrapper);
public:
static ConsumerWrapper* create(WebAudioDestinationConsumer* consumer) {
return new ConsumerWrapper(consumer);
......@@ -196,12 +198,10 @@ bool WebMediaStreamSource::removeAudioConsumer(
ASSERT(isMainThread());
ASSERT(!m_private.isNull() && consumer);
const HeapHashSet<Member<AudioDestinationConsumer>>& consumers =
const HashSet<AudioDestinationConsumer*>& consumers =
m_private->audioConsumers();
for (HeapHashSet<Member<AudioDestinationConsumer>>::const_iterator it =
consumers.begin();
it != consumers.end(); ++it) {
ConsumerWrapper* wrapper = static_cast<ConsumerWrapper*>(it->get());
for (AudioDestinationConsumer* it : consumers) {
ConsumerWrapper* wrapper = static_cast<ConsumerWrapper*>(it);
if (wrapper->consumer() == consumer) {
m_private->removeAudioConsumer(wrapper);
return true;
......
......@@ -85,8 +85,7 @@ bool MediaStreamSource::removeAudioConsumer(
AudioDestinationConsumer* consumer) {
ASSERT(m_requiresConsumer);
MutexLocker locker(m_audioConsumersLock);
HeapHashSet<Member<AudioDestinationConsumer>>::iterator it =
m_audioConsumers.find(consumer);
auto it = m_audioConsumers.find(consumer);
if (it == m_audioConsumers.end())
return false;
m_audioConsumers.erase(it);
......@@ -101,24 +100,19 @@ void MediaStreamSource::setAudioFormat(size_t numberOfChannels,
float sampleRate) {
ASSERT(m_requiresConsumer);
MutexLocker locker(m_audioConsumersLock);
for (HeapHashSet<Member<AudioDestinationConsumer>>::iterator it =
m_audioConsumers.begin();
it != m_audioConsumers.end(); ++it)
(*it)->setFormat(numberOfChannels, sampleRate);
for (AudioDestinationConsumer* consumer : m_audioConsumers)
consumer->setFormat(numberOfChannels, sampleRate);
}
void MediaStreamSource::consumeAudio(AudioBus* bus, size_t numberOfFrames) {
ASSERT(m_requiresConsumer);
MutexLocker locker(m_audioConsumersLock);
for (HeapHashSet<Member<AudioDestinationConsumer>>::iterator it =
m_audioConsumers.begin();
it != m_audioConsumers.end(); ++it)
(*it)->consumeAudio(bus, numberOfFrames);
for (AudioDestinationConsumer* consumer : m_audioConsumers)
consumer->consumeAudio(bus, numberOfFrames);
}
DEFINE_TRACE(MediaStreamSource) {
visitor->trace(m_observers);
visitor->trace(m_audioConsumers);
}
} // namespace blink
......@@ -102,7 +102,7 @@ class PLATFORM_EXPORT MediaStreamSource final
bool requiresAudioConsumer() const { return m_requiresConsumer; }
void addAudioConsumer(AudioDestinationConsumer*);
bool removeAudioConsumer(AudioDestinationConsumer*);
const HeapHashSet<Member<AudioDestinationConsumer>>& audioConsumers() {
const HashSet<AudioDestinationConsumer*>& audioConsumers() {
return m_audioConsumers;
}
......@@ -126,7 +126,7 @@ class PLATFORM_EXPORT MediaStreamSource final
bool m_requiresConsumer;
HeapHashSet<WeakMember<Observer>> m_observers;
Mutex m_audioConsumersLock;
HeapHashSet<Member<AudioDestinationConsumer>> m_audioConsumers;
HashSet<AudioDestinationConsumer*> m_audioConsumers;
std::unique_ptr<ExtraData> m_extraData;
WebMediaConstraints m_constraints;
};
......
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