OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2010, Google Inc. All rights reserved. | 2 * Copyright (C) 2010, 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
43 return adoptRef(new AnalyserHandler(node, sampleRate)); | 43 return adoptRef(new AnalyserHandler(node, sampleRate)); |
44 } | 44 } |
45 | 45 |
46 AnalyserHandler::~AnalyserHandler() { | 46 AnalyserHandler::~AnalyserHandler() { |
47 uninitialize(); | 47 uninitialize(); |
48 } | 48 } |
49 | 49 |
50 void AnalyserHandler::process(size_t framesToProcess) { | 50 void AnalyserHandler::process(size_t framesToProcess) { |
51 AudioBus* outputBus = output(0).bus(); | 51 AudioBus* outputBus = output(0).bus(); |
52 | 52 |
53 if (!isInitialized() || !input(0).isConnected()) { | 53 if (!isInitialized()) { |
54 outputBus->zero(); | 54 outputBus->zero(); |
55 return; | 55 return; |
56 } | 56 } |
57 | 57 |
58 // Must update the internal state even if there are no inputs. | |
hongchan
2017/02/01 01:12:11
Not sure where this comment should be placed.
Raymond Toy
2017/02/01 21:23:47
Would it help to rephrase it? Or just remove it? (
hongchan
2017/02/03 18:47:40
The comment is not really relevant to what's happe
Raymond Toy
2017/02/03 18:50:00
How about:
// Must always update internal state w
| |
58 AudioBus* inputBus = input(0).bus(); | 59 AudioBus* inputBus = input(0).bus(); |
59 | 60 |
60 // Give the analyser the audio which is passing through this AudioNode. | 61 // Give the analyser the audio which is passing through this AudioNode. |
61 m_analyser.writeInput(inputBus, framesToProcess); | 62 m_analyser.writeInput(inputBus, framesToProcess); |
62 | 63 |
64 if (!input(0).isConnected()) { | |
65 // No inputs, so clear the output, and propagate the silence hint. | |
66 outputBus->zero(); | |
67 return; | |
68 } | |
69 | |
63 // For in-place processing, our override of pullInputs() will just pass the | 70 // For in-place processing, our override of pullInputs() will just pass the |
64 // audio data through unchanged if the channel count matches from input to | 71 // audio data through unchanged if the channel count matches from input to |
65 // output (resulting in inputBus == outputBus). Otherwise, do an up-mix to | 72 // output (resulting in inputBus == outputBus). Otherwise, do an up-mix to |
66 // stereo. | 73 // stereo. |
67 if (inputBus != outputBus) | 74 if (inputBus != outputBus) |
68 outputBus->copyFrom(*inputBus); | 75 outputBus->copyFrom(*inputBus); |
69 } | 76 } |
70 | 77 |
71 void AnalyserHandler::setFftSize(unsigned size, | 78 void AnalyserHandler::setFftSize(unsigned size, |
72 ExceptionState& exceptionState) { | 79 ExceptionState& exceptionState) { |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
235 | 242 |
236 void AnalyserNode::getFloatTimeDomainData(DOMFloat32Array* array) { | 243 void AnalyserNode::getFloatTimeDomainData(DOMFloat32Array* array) { |
237 analyserHandler().getFloatTimeDomainData(array); | 244 analyserHandler().getFloatTimeDomainData(array); |
238 } | 245 } |
239 | 246 |
240 void AnalyserNode::getByteTimeDomainData(DOMUint8Array* array) { | 247 void AnalyserNode::getByteTimeDomainData(DOMUint8Array* array) { |
241 analyserHandler().getByteTimeDomainData(array); | 248 analyserHandler().getByteTimeDomainData(array); |
242 } | 249 } |
243 | 250 |
244 } // namespace blink | 251 } // namespace blink |
OLD | NEW |