| 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 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 // Do any necesssary re-configuration to the output's number of chan
nels. | 77 // Do any necesssary re-configuration to the output's number of chan
nels. |
| 78 output(0).setNumberOfChannels(numberOfChannels); | 78 output(0).setNumberOfChannels(numberOfChannels); |
| 79 } | 79 } |
| 80 } | 80 } |
| 81 } | 81 } |
| 82 | 82 |
| 83 void MediaStreamAudioSourceHandler::process(size_t numberOfFrames) | 83 void MediaStreamAudioSourceHandler::process(size_t numberOfFrames) |
| 84 { | 84 { |
| 85 AudioBus* outputBus = output(0).bus(); | 85 AudioBus* outputBus = output(0).bus(); |
| 86 | 86 |
| 87 if (!audioSourceProvider()) { | 87 if (!getAudioSourceProvider()) { |
| 88 outputBus->zero(); | 88 outputBus->zero(); |
| 89 return; | 89 return; |
| 90 } | 90 } |
| 91 | 91 |
| 92 if (!mediaStream() || m_sourceNumberOfChannels != outputBus->numberOfChannel
s()) { | 92 if (!getMediaStream() || m_sourceNumberOfChannels != outputBus->numberOfChan
nels()) { |
| 93 outputBus->zero(); | 93 outputBus->zero(); |
| 94 return; | 94 return; |
| 95 } | 95 } |
| 96 | 96 |
| 97 // Use a tryLock() to avoid contention in the real-time audio thread. | 97 // Use a tryLock() to avoid contention in the real-time audio thread. |
| 98 // If we fail to acquire the lock then the MediaStream must be in the middle
of | 98 // If we fail to acquire the lock then the MediaStream must be in the middle
of |
| 99 // a format change, so we output silence in this case. | 99 // a format change, so we output silence in this case. |
| 100 MutexTryLocker tryLocker(m_processLock); | 100 MutexTryLocker tryLocker(m_processLock); |
| 101 if (tryLocker.locked()) { | 101 if (tryLocker.locked()) { |
| 102 audioSourceProvider()->provideInput(outputBus, numberOfFrames); | 102 getAudioSourceProvider()->provideInput(outputBus, numberOfFrames); |
| 103 } else { | 103 } else { |
| 104 // We failed to acquire the lock. | 104 // We failed to acquire the lock. |
| 105 outputBus->zero(); | 105 outputBus->zero(); |
| 106 } | 106 } |
| 107 } | 107 } |
| 108 | 108 |
| 109 // ---------------------------------------------------------------- | 109 // ---------------------------------------------------------------- |
| 110 | 110 |
| 111 MediaStreamAudioSourceNode::MediaStreamAudioSourceNode(AbstractAudioContext& con
text, MediaStream& mediaStream, MediaStreamTrack* audioTrack, PassOwnPtr<AudioSo
urceProvider> audioSourceProvider) | 111 MediaStreamAudioSourceNode::MediaStreamAudioSourceNode(AbstractAudioContext& con
text, MediaStream& mediaStream, MediaStreamTrack* audioTrack, PassOwnPtr<AudioSo
urceProvider> audioSourceProvider) |
| 112 : AudioSourceNode(context) | 112 : AudioSourceNode(context) |
| (...skipping 10 matching lines...) Expand all Loading... |
| 123 { | 123 { |
| 124 AudioSourceProviderClient::trace(visitor); | 124 AudioSourceProviderClient::trace(visitor); |
| 125 AudioSourceNode::trace(visitor); | 125 AudioSourceNode::trace(visitor); |
| 126 } | 126 } |
| 127 | 127 |
| 128 MediaStreamAudioSourceHandler& MediaStreamAudioSourceNode::mediaStreamAudioSourc
eHandler() const | 128 MediaStreamAudioSourceHandler& MediaStreamAudioSourceNode::mediaStreamAudioSourc
eHandler() const |
| 129 { | 129 { |
| 130 return static_cast<MediaStreamAudioSourceHandler&>(handler()); | 130 return static_cast<MediaStreamAudioSourceHandler&>(handler()); |
| 131 } | 131 } |
| 132 | 132 |
| 133 MediaStream* MediaStreamAudioSourceNode::mediaStream() const | 133 MediaStream* MediaStreamAudioSourceNode::getMediaStream() const |
| 134 { | 134 { |
| 135 return mediaStreamAudioSourceHandler().mediaStream(); | 135 return mediaStreamAudioSourceHandler().getMediaStream(); |
| 136 } | 136 } |
| 137 | 137 |
| 138 void MediaStreamAudioSourceNode::setFormat(size_t numberOfChannels, float source
SampleRate) | 138 void MediaStreamAudioSourceNode::setFormat(size_t numberOfChannels, float source
SampleRate) |
| 139 { | 139 { |
| 140 mediaStreamAudioSourceHandler().setFormat(numberOfChannels, sourceSampleRate
); | 140 mediaStreamAudioSourceHandler().setFormat(numberOfChannels, sourceSampleRate
); |
| 141 } | 141 } |
| 142 | 142 |
| 143 } // namespace blink | 143 } // namespace blink |
| 144 | 144 |
| OLD | NEW |