| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 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 | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 , m_readonly(readonly) | 46 , m_readonly(readonly) |
| 47 , m_readyState(readyState) | 47 , m_readyState(readyState) |
| 48 , m_requiresConsumer(requiresConsumer) | 48 , m_requiresConsumer(requiresConsumer) |
| 49 { | 49 { |
| 50 } | 50 } |
| 51 | 51 |
| 52 void MediaStreamSource::setReadyState(ReadyState readyState) | 52 void MediaStreamSource::setReadyState(ReadyState readyState) |
| 53 { | 53 { |
| 54 if (m_readyState != ReadyStateEnded && m_readyState != readyState) { | 54 if (m_readyState != ReadyStateEnded && m_readyState != readyState) { |
| 55 m_readyState = readyState; | 55 m_readyState = readyState; |
| 56 for (auto i = m_observers.begin(); i != m_observers.end(); ++i) | 56 |
| 57 (*i)->sourceChangedState(); | 57 // Observers may dispatch events which create and add new Observers; |
| 58 // take a snapshot so as to safely iterate. |
| 59 HeapVector<Member<Observer>> observers; |
| 60 copyToVector(m_observers, observers); |
| 61 for (auto observer : observers) |
| 62 observer->sourceChangedState(); |
| 58 } | 63 } |
| 59 } | 64 } |
| 60 | 65 |
| 61 void MediaStreamSource::addObserver(MediaStreamSource::Observer* observer) | 66 void MediaStreamSource::addObserver(MediaStreamSource::Observer* observer) |
| 62 { | 67 { |
| 63 m_observers.add(observer); | 68 m_observers.add(observer); |
| 64 } | 69 } |
| 65 | 70 |
| 66 void MediaStreamSource::addAudioConsumer(AudioDestinationConsumer* consumer) | 71 void MediaStreamSource::addAudioConsumer(AudioDestinationConsumer* consumer) |
| 67 { | 72 { |
| (...skipping 29 matching lines...) Expand all Loading... |
| 97 (*it)->consumeAudio(bus, numberOfFrames); | 102 (*it)->consumeAudio(bus, numberOfFrames); |
| 98 } | 103 } |
| 99 | 104 |
| 100 DEFINE_TRACE(MediaStreamSource) | 105 DEFINE_TRACE(MediaStreamSource) |
| 101 { | 106 { |
| 102 visitor->trace(m_observers); | 107 visitor->trace(m_observers); |
| 103 visitor->trace(m_audioConsumers); | 108 visitor->trace(m_audioConsumers); |
| 104 } | 109 } |
| 105 | 110 |
| 106 } // namespace blink | 111 } // namespace blink |
| OLD | NEW |