Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(154)

Side by Side Diff: third_party/WebKit/Source/modules/webaudio/MediaStreamAudioSourceNode.cpp

Issue 2103043007: Rename AbstractAudioContext to BaseAudioContext (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use ASSERT(isGraphOwner()) instead of DCHECK Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
11 * documentation and/or other materials provided with the distribution. 11 * documentation and/or other materials provided with the distribution.
12 * 12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND AN Y 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND AN Y
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
15 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 15 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
16 * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR AN Y 16 * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR AN Y
17 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 17 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
18 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 18 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
19 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND O N 19 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND O N
20 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 20 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
22 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 22 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 */ 23 */
24 24
25 #include "modules/webaudio/MediaStreamAudioSourceNode.h" 25 #include "modules/webaudio/MediaStreamAudioSourceNode.h"
26 26
27 #include "core/dom/ExceptionCode.h" 27 #include "core/dom/ExceptionCode.h"
28 #include "modules/webaudio/AbstractAudioContext.h"
29 #include "modules/webaudio/AudioNodeOutput.h" 28 #include "modules/webaudio/AudioNodeOutput.h"
29 #include "modules/webaudio/BaseAudioContext.h"
30 #include "platform/Logging.h" 30 #include "platform/Logging.h"
31 #include "wtf/Locker.h" 31 #include "wtf/Locker.h"
32 #include <memory> 32 #include <memory>
33 33
34 namespace blink { 34 namespace blink {
35 35
36 MediaStreamAudioSourceHandler::MediaStreamAudioSourceHandler(AudioNode& node, Me diaStream& mediaStream, MediaStreamTrack* audioTrack, std::unique_ptr<AudioSourc eProvider> audioSourceProvider) 36 MediaStreamAudioSourceHandler::MediaStreamAudioSourceHandler(AudioNode& node, Me diaStream& mediaStream, MediaStreamTrack* audioTrack, std::unique_ptr<AudioSourc eProvider> audioSourceProvider)
37 : AudioHandler(NodeTypeMediaStreamAudioSource, node, node.context()->sampleR ate()) 37 : AudioHandler(NodeTypeMediaStreamAudioSource, node, node.context()->sampleR ate())
38 , m_mediaStream(mediaStream) 38 , m_mediaStream(mediaStream)
39 , m_audioTrack(audioTrack) 39 , m_audioTrack(audioTrack)
(...skipping 14 matching lines...) Expand all
54 54
55 MediaStreamAudioSourceHandler::~MediaStreamAudioSourceHandler() 55 MediaStreamAudioSourceHandler::~MediaStreamAudioSourceHandler()
56 { 56 {
57 uninitialize(); 57 uninitialize();
58 } 58 }
59 59
60 void MediaStreamAudioSourceHandler::setFormat(size_t numberOfChannels, float sou rceSampleRate) 60 void MediaStreamAudioSourceHandler::setFormat(size_t numberOfChannels, float sou rceSampleRate)
61 { 61 {
62 if (numberOfChannels != m_sourceNumberOfChannels || sourceSampleRate != samp leRate()) { 62 if (numberOfChannels != m_sourceNumberOfChannels || sourceSampleRate != samp leRate()) {
63 // The sample-rate must be equal to the context's sample-rate. 63 // The sample-rate must be equal to the context's sample-rate.
64 if (!numberOfChannels || numberOfChannels > AbstractAudioContext::maxNum berOfChannels() || sourceSampleRate != sampleRate()) { 64 if (!numberOfChannels || numberOfChannels > BaseAudioContext::maxNumberO fChannels() || sourceSampleRate != sampleRate()) {
65 // process() will generate silence for these uninitialized values. 65 // process() will generate silence for these uninitialized values.
66 DLOG(ERROR) << "setFormat(" << numberOfChannels << ", " << sourceSam pleRate << ") - unhandled format change"; 66 DLOG(ERROR) << "setFormat(" << numberOfChannels << ", " << sourceSam pleRate << ") - unhandled format change";
67 m_sourceNumberOfChannels = 0; 67 m_sourceNumberOfChannels = 0;
68 return; 68 return;
69 } 69 }
70 70
71 // Synchronize with process(). 71 // Synchronize with process().
72 MutexLocker locker(m_processLock); 72 MutexLocker locker(m_processLock);
73 73
74 m_sourceNumberOfChannels = numberOfChannels; 74 m_sourceNumberOfChannels = numberOfChannels;
75 75
76 { 76 {
77 // The context must be locked when changing the number of output cha nnels. 77 // The context must be locked when changing the number of output cha nnels.
78 AbstractAudioContext::AutoLocker contextLocker(context()); 78 BaseAudioContext::AutoLocker contextLocker(context());
79 79
80 // Do any necesssary re-configuration to the output's number of chan nels. 80 // Do any necesssary re-configuration to the output's number of chan nels.
81 output(0).setNumberOfChannels(numberOfChannels); 81 output(0).setNumberOfChannels(numberOfChannels);
82 } 82 }
83 } 83 }
84 } 84 }
85 85
86 void MediaStreamAudioSourceHandler::process(size_t numberOfFrames) 86 void MediaStreamAudioSourceHandler::process(size_t numberOfFrames)
87 { 87 {
88 AudioBus* outputBus = output(0).bus(); 88 AudioBus* outputBus = output(0).bus();
(...skipping 15 matching lines...) Expand all
104 if (tryLocker.locked()) { 104 if (tryLocker.locked()) {
105 getAudioSourceProvider()->provideInput(outputBus, numberOfFrames); 105 getAudioSourceProvider()->provideInput(outputBus, numberOfFrames);
106 } else { 106 } else {
107 // We failed to acquire the lock. 107 // We failed to acquire the lock.
108 outputBus->zero(); 108 outputBus->zero();
109 } 109 }
110 } 110 }
111 111
112 // ---------------------------------------------------------------- 112 // ----------------------------------------------------------------
113 113
114 MediaStreamAudioSourceNode::MediaStreamAudioSourceNode(AbstractAudioContext& con text, MediaStream& mediaStream, MediaStreamTrack* audioTrack, std::unique_ptr<Au dioSourceProvider> audioSourceProvider) 114 MediaStreamAudioSourceNode::MediaStreamAudioSourceNode(BaseAudioContext& context , MediaStream& mediaStream, MediaStreamTrack* audioTrack, std::unique_ptr<AudioS ourceProvider> audioSourceProvider)
115 : AudioSourceNode(context) 115 : AudioSourceNode(context)
116 { 116 {
117 setHandler(MediaStreamAudioSourceHandler::create(*this, mediaStream, audioTr ack, std::move(audioSourceProvider))); 117 setHandler(MediaStreamAudioSourceHandler::create(*this, mediaStream, audioTr ack, std::move(audioSourceProvider)));
118 } 118 }
119 119
120 MediaStreamAudioSourceNode* MediaStreamAudioSourceNode::create(AbstractAudioCont ext& context, MediaStream& mediaStream, ExceptionState& exceptionState) 120 MediaStreamAudioSourceNode* MediaStreamAudioSourceNode::create(BaseAudioContext& context, MediaStream& mediaStream, ExceptionState& exceptionState)
121 { 121 {
122 DCHECK(isMainThread()); 122 DCHECK(isMainThread());
123 123
124 if (context.isContextClosed()) { 124 if (context.isContextClosed()) {
125 context.throwExceptionForClosedState(exceptionState); 125 context.throwExceptionForClosedState(exceptionState);
126 return nullptr; 126 return nullptr;
127 } 127 }
128 128
129 MediaStreamTrackVector audioTracks = mediaStream.getAudioTracks(); 129 MediaStreamTrackVector audioTracks = mediaStream.getAudioTracks();
130 if (audioTracks.isEmpty()) { 130 if (audioTracks.isEmpty()) {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 return mediaStreamAudioSourceHandler().getMediaStream(); 168 return mediaStreamAudioSourceHandler().getMediaStream();
169 } 169 }
170 170
171 void MediaStreamAudioSourceNode::setFormat(size_t numberOfChannels, float source SampleRate) 171 void MediaStreamAudioSourceNode::setFormat(size_t numberOfChannels, float source SampleRate)
172 { 172 {
173 mediaStreamAudioSourceHandler().setFormat(numberOfChannels, sourceSampleRate ); 173 mediaStreamAudioSourceHandler().setFormat(numberOfChannels, sourceSampleRate );
174 } 174 }
175 175
176 } // namespace blink 176 } // namespace blink
177 177
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698