| 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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 void MediaStreamSource::addAudioConsumer(AudioDestinationConsumer* consumer) { | 78 void MediaStreamSource::addAudioConsumer(AudioDestinationConsumer* consumer) { |
| 79 ASSERT(m_requiresConsumer); | 79 ASSERT(m_requiresConsumer); |
| 80 MutexLocker locker(m_audioConsumersLock); | 80 MutexLocker locker(m_audioConsumersLock); |
| 81 m_audioConsumers.insert(consumer); | 81 m_audioConsumers.insert(consumer); |
| 82 } | 82 } |
| 83 | 83 |
| 84 bool MediaStreamSource::removeAudioConsumer( | 84 bool MediaStreamSource::removeAudioConsumer( |
| 85 AudioDestinationConsumer* consumer) { | 85 AudioDestinationConsumer* consumer) { |
| 86 ASSERT(m_requiresConsumer); | 86 ASSERT(m_requiresConsumer); |
| 87 MutexLocker locker(m_audioConsumersLock); | 87 MutexLocker locker(m_audioConsumersLock); |
| 88 HeapHashSet<Member<AudioDestinationConsumer>>::iterator it = | 88 auto it = m_audioConsumers.find(consumer); |
| 89 m_audioConsumers.find(consumer); | |
| 90 if (it == m_audioConsumers.end()) | 89 if (it == m_audioConsumers.end()) |
| 91 return false; | 90 return false; |
| 92 m_audioConsumers.erase(it); | 91 m_audioConsumers.erase(it); |
| 93 return true; | 92 return true; |
| 94 } | 93 } |
| 95 | 94 |
| 96 void MediaStreamSource::getSettings(WebMediaStreamTrack::Settings& settings) { | 95 void MediaStreamSource::getSettings(WebMediaStreamTrack::Settings& settings) { |
| 97 settings.deviceId = id(); | 96 settings.deviceId = id(); |
| 98 } | 97 } |
| 99 | 98 |
| 100 void MediaStreamSource::setAudioFormat(size_t numberOfChannels, | 99 void MediaStreamSource::setAudioFormat(size_t numberOfChannels, |
| 101 float sampleRate) { | 100 float sampleRate) { |
| 102 ASSERT(m_requiresConsumer); | 101 ASSERT(m_requiresConsumer); |
| 103 MutexLocker locker(m_audioConsumersLock); | 102 MutexLocker locker(m_audioConsumersLock); |
| 104 for (HeapHashSet<Member<AudioDestinationConsumer>>::iterator it = | 103 for (AudioDestinationConsumer* consumer : m_audioConsumers) |
| 105 m_audioConsumers.begin(); | 104 consumer->setFormat(numberOfChannels, sampleRate); |
| 106 it != m_audioConsumers.end(); ++it) | |
| 107 (*it)->setFormat(numberOfChannels, sampleRate); | |
| 108 } | 105 } |
| 109 | 106 |
| 110 void MediaStreamSource::consumeAudio(AudioBus* bus, size_t numberOfFrames) { | 107 void MediaStreamSource::consumeAudio(AudioBus* bus, size_t numberOfFrames) { |
| 111 ASSERT(m_requiresConsumer); | 108 ASSERT(m_requiresConsumer); |
| 112 MutexLocker locker(m_audioConsumersLock); | 109 MutexLocker locker(m_audioConsumersLock); |
| 113 for (HeapHashSet<Member<AudioDestinationConsumer>>::iterator it = | 110 for (AudioDestinationConsumer* consumer : m_audioConsumers) |
| 114 m_audioConsumers.begin(); | 111 consumer->consumeAudio(bus, numberOfFrames); |
| 115 it != m_audioConsumers.end(); ++it) | |
| 116 (*it)->consumeAudio(bus, numberOfFrames); | |
| 117 } | 112 } |
| 118 | 113 |
| 119 DEFINE_TRACE(MediaStreamSource) { | 114 DEFINE_TRACE(MediaStreamSource) { |
| 120 visitor->trace(m_observers); | 115 visitor->trace(m_observers); |
| 121 visitor->trace(m_audioConsumers); | |
| 122 } | 116 } |
| 123 | 117 |
| 124 } // namespace blink | 118 } // namespace blink |
| OLD | NEW |