| 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 } | 59 } |
| 60 | 60 |
| 61 void MediaStreamSource::addObserver(MediaStreamSource::Observer* observer) | 61 void MediaStreamSource::addObserver(MediaStreamSource::Observer* observer) |
| 62 { | 62 { |
| 63 m_observers.append(observer); | 63 m_observers.append(observer); |
| 64 } | 64 } |
| 65 | 65 |
| 66 void MediaStreamSource::removeObserver(MediaStreamSource::Observer* observer) | 66 void MediaStreamSource::removeObserver(MediaStreamSource::Observer* observer) |
| 67 { | 67 { |
| 68 size_t pos = m_observers.find(observer); | 68 size_t pos = m_observers.find(observer); |
| 69 if (pos != notFound) | 69 if (pos != kNotFound) |
| 70 m_observers.remove(pos); | 70 m_observers.remove(pos); |
| 71 } | 71 } |
| 72 | 72 |
| 73 void MediaStreamSource::addAudioConsumer(PassRefPtr<AudioDestinationConsumer> co
nsumer) | 73 void MediaStreamSource::addAudioConsumer(PassRefPtr<AudioDestinationConsumer> co
nsumer) |
| 74 { | 74 { |
| 75 ASSERT(m_requiresConsumer); | 75 ASSERT(m_requiresConsumer); |
| 76 MutexLocker locker(m_audioConsumersLock); | 76 MutexLocker locker(m_audioConsumersLock); |
| 77 m_audioConsumers.append(consumer); | 77 m_audioConsumers.append(consumer); |
| 78 } | 78 } |
| 79 | 79 |
| 80 bool MediaStreamSource::removeAudioConsumer(AudioDestinationConsumer* consumer) | 80 bool MediaStreamSource::removeAudioConsumer(AudioDestinationConsumer* consumer) |
| 81 { | 81 { |
| 82 ASSERT(m_requiresConsumer); | 82 ASSERT(m_requiresConsumer); |
| 83 MutexLocker locker(m_audioConsumersLock); | 83 MutexLocker locker(m_audioConsumersLock); |
| 84 size_t pos = m_audioConsumers.find(consumer); | 84 size_t pos = m_audioConsumers.find(consumer); |
| 85 if (pos != notFound) { | 85 if (pos != kNotFound) { |
| 86 m_audioConsumers.remove(pos); | 86 m_audioConsumers.remove(pos); |
| 87 return true; | 87 return true; |
| 88 } | 88 } |
| 89 return false; | 89 return false; |
| 90 } | 90 } |
| 91 | 91 |
| 92 void MediaStreamSource::setAudioFormat(size_t numberOfChannels, float sampleRate
) | 92 void MediaStreamSource::setAudioFormat(size_t numberOfChannels, float sampleRate
) |
| 93 { | 93 { |
| 94 ASSERT(m_requiresConsumer); | 94 ASSERT(m_requiresConsumer); |
| 95 MutexLocker locker(m_audioConsumersLock); | 95 MutexLocker locker(m_audioConsumersLock); |
| 96 for (Vector<RefPtr<AudioDestinationConsumer> >::iterator it = m_audioConsume
rs.begin(); it != m_audioConsumers.end(); ++it) | 96 for (Vector<RefPtr<AudioDestinationConsumer> >::iterator it = m_audioConsume
rs.begin(); it != m_audioConsumers.end(); ++it) |
| 97 (*it)->setFormat(numberOfChannels, sampleRate); | 97 (*it)->setFormat(numberOfChannels, sampleRate); |
| 98 } | 98 } |
| 99 | 99 |
| 100 void MediaStreamSource::consumeAudio(AudioBus* bus, size_t numberOfFrames) | 100 void MediaStreamSource::consumeAudio(AudioBus* bus, size_t numberOfFrames) |
| 101 { | 101 { |
| 102 ASSERT(m_requiresConsumer); | 102 ASSERT(m_requiresConsumer); |
| 103 MutexLocker locker(m_audioConsumersLock); | 103 MutexLocker locker(m_audioConsumersLock); |
| 104 for (Vector<RefPtr<AudioDestinationConsumer> >::iterator it = m_audioConsume
rs.begin(); it != m_audioConsumers.end(); ++it) | 104 for (Vector<RefPtr<AudioDestinationConsumer> >::iterator it = m_audioConsume
rs.begin(); it != m_audioConsumers.end(); ++it) |
| 105 (*it)->consumeAudio(bus, numberOfFrames); | 105 (*it)->consumeAudio(bus, numberOfFrames); |
| 106 } | 106 } |
| 107 | 107 |
| 108 } // namespace WebCore | 108 } // namespace WebCore |
| OLD | NEW |