OLD | NEW |
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 Loading... |
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 | |
153 public: | 151 public: |
154 static ConsumerWrapper* create(WebAudioDestinationConsumer* consumer) { | 152 static ConsumerWrapper* create(WebAudioDestinationConsumer* consumer) { |
155 return new ConsumerWrapper(consumer); | 153 return new ConsumerWrapper(consumer); |
156 } | 154 } |
157 | 155 |
158 void setFormat(size_t numberOfChannels, float sampleRate) override; | 156 void setFormat(size_t numberOfChannels, float sampleRate) override; |
159 void consumeAudio(AudioBus*, size_t numberOfFrames) override; | 157 void consumeAudio(AudioBus*, size_t numberOfFrames) override; |
160 | 158 |
161 WebAudioDestinationConsumer* consumer() { return m_consumer; } | 159 WebAudioDestinationConsumer* consumer() { return m_consumer; } |
162 | 160 |
(...skipping 28 matching lines...) Expand all Loading... |
191 ASSERT(!m_private.isNull() && consumer); | 189 ASSERT(!m_private.isNull() && consumer); |
192 | 190 |
193 m_private->addAudioConsumer(ConsumerWrapper::create(consumer)); | 191 m_private->addAudioConsumer(ConsumerWrapper::create(consumer)); |
194 } | 192 } |
195 | 193 |
196 bool WebMediaStreamSource::removeAudioConsumer( | 194 bool WebMediaStreamSource::removeAudioConsumer( |
197 WebAudioDestinationConsumer* consumer) { | 195 WebAudioDestinationConsumer* consumer) { |
198 ASSERT(isMainThread()); | 196 ASSERT(isMainThread()); |
199 ASSERT(!m_private.isNull() && consumer); | 197 ASSERT(!m_private.isNull() && consumer); |
200 | 198 |
201 const HashSet<AudioDestinationConsumer*>& consumers = | 199 const HeapHashSet<Member<AudioDestinationConsumer>>& consumers = |
202 m_private->audioConsumers(); | 200 m_private->audioConsumers(); |
203 for (AudioDestinationConsumer* it : consumers) { | 201 for (HeapHashSet<Member<AudioDestinationConsumer>>::const_iterator it = |
204 ConsumerWrapper* wrapper = static_cast<ConsumerWrapper*>(it); | 202 consumers.begin(); |
| 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 |
OLD | NEW |