Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(497)

Side by Side Diff: third_party/WebKit/Source/platform/exported/WebMediaStreamSource.cpp

Issue 2748133003: Pull AudioDestinationConsumer off the Blink GC heap. (Closed)
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 ASSERT(!m_private.isNull()); 141 ASSERT(!m_private.isNull());
142 return m_private->constraints(); 142 return m_private->constraints();
143 } 143 }
144 144
145 bool WebMediaStreamSource::requiresAudioConsumer() const { 145 bool WebMediaStreamSource::requiresAudioConsumer() const {
146 ASSERT(!m_private.isNull()); 146 ASSERT(!m_private.isNull());
147 return m_private->requiresAudioConsumer(); 147 return m_private->requiresAudioConsumer();
148 } 148 }
149 149
150 class ConsumerWrapper final : public AudioDestinationConsumer { 150 class ConsumerWrapper final : public AudioDestinationConsumer {
151 USING_FAST_MALLOC(ConsumerWrapper);
152
151 public: 153 public:
152 static ConsumerWrapper* create(WebAudioDestinationConsumer* consumer) { 154 static ConsumerWrapper* create(WebAudioDestinationConsumer* consumer) {
153 return new ConsumerWrapper(consumer); 155 return new ConsumerWrapper(consumer);
154 } 156 }
155 157
156 void setFormat(size_t numberOfChannels, float sampleRate) override; 158 void setFormat(size_t numberOfChannels, float sampleRate) override;
157 void consumeAudio(AudioBus*, size_t numberOfFrames) override; 159 void consumeAudio(AudioBus*, size_t numberOfFrames) override;
158 160
159 WebAudioDestinationConsumer* consumer() { return m_consumer; } 161 WebAudioDestinationConsumer* consumer() { return m_consumer; }
160 162
(...skipping 28 matching lines...) Expand all
189 ASSERT(!m_private.isNull() && consumer); 191 ASSERT(!m_private.isNull() && consumer);
190 192
191 m_private->addAudioConsumer(ConsumerWrapper::create(consumer)); 193 m_private->addAudioConsumer(ConsumerWrapper::create(consumer));
192 } 194 }
193 195
194 bool WebMediaStreamSource::removeAudioConsumer( 196 bool WebMediaStreamSource::removeAudioConsumer(
195 WebAudioDestinationConsumer* consumer) { 197 WebAudioDestinationConsumer* consumer) {
196 ASSERT(isMainThread()); 198 ASSERT(isMainThread());
197 ASSERT(!m_private.isNull() && consumer); 199 ASSERT(!m_private.isNull() && consumer);
198 200
199 const HeapHashSet<Member<AudioDestinationConsumer>>& consumers = 201 const HashSet<AudioDestinationConsumer*>& consumers =
200 m_private->audioConsumers(); 202 m_private->audioConsumers();
201 for (HeapHashSet<Member<AudioDestinationConsumer>>::const_iterator it = 203 for (AudioDestinationConsumer* it : consumers) {
202 consumers.begin(); 204 ConsumerWrapper* wrapper = static_cast<ConsumerWrapper*>(it);
203 it != consumers.end(); ++it) {
204 ConsumerWrapper* wrapper = static_cast<ConsumerWrapper*>(it->get());
205 if (wrapper->consumer() == consumer) { 205 if (wrapper->consumer() == consumer) {
206 m_private->removeAudioConsumer(wrapper); 206 m_private->removeAudioConsumer(wrapper);
207 return true; 207 return true;
208 } 208 }
209 } 209 }
210 return false; 210 return false;
211 } 211 }
212 212
213 } // namespace blink 213 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698