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 27 matching lines...) Expand all Loading... |
38 #include <stdio.h> | 38 #include <stdio.h> |
39 #endif | 39 #endif |
40 | 40 |
41 namespace blink { | 41 namespace blink { |
42 | 42 |
43 AudioHandler::AudioHandler(NodeType nodeType, AudioNode& node, float sampleRate) | 43 AudioHandler::AudioHandler(NodeType nodeType, AudioNode& node, float sampleRate) |
44 : m_isInitialized(false), | 44 : m_isInitialized(false), |
45 m_nodeType(NodeTypeUnknown), | 45 m_nodeType(NodeTypeUnknown), |
46 m_node(&node), | 46 m_node(&node), |
47 m_context(node.context()), | 47 m_context(node.context()), |
48 m_sampleRate(sampleRate), | |
49 m_lastProcessingTime(-1), | 48 m_lastProcessingTime(-1), |
50 m_lastNonSilentTime(-1), | 49 m_lastNonSilentTime(-1), |
51 m_connectionRefCount(0), | 50 m_connectionRefCount(0), |
52 m_isDisabled(false), | 51 m_isDisabled(false), |
53 m_channelCount(2) { | 52 m_channelCount(2) { |
54 setNodeType(nodeType); | 53 setNodeType(nodeType); |
55 setInternalChannelCountMode(Max); | 54 setInternalChannelCountMode(Max); |
56 setInternalChannelInterpretation(AudioBus::Speakers); | 55 setInternalChannelInterpretation(AudioBus::Speakers); |
57 | 56 |
58 #if DEBUG_AUDIONODE_REFERENCES | 57 #if DEBUG_AUDIONODE_REFERENCES |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 // have the results cached in their bus; | 315 // have the results cached in their bus; |
317 double currentTime = context()->currentTime(); | 316 double currentTime = context()->currentTime(); |
318 if (m_lastProcessingTime != currentTime) { | 317 if (m_lastProcessingTime != currentTime) { |
319 // important to first update this time because of feedback loops in the | 318 // important to first update this time because of feedback loops in the |
320 // rendering graph. | 319 // rendering graph. |
321 m_lastProcessingTime = currentTime; | 320 m_lastProcessingTime = currentTime; |
322 | 321 |
323 pullInputs(framesToProcess); | 322 pullInputs(framesToProcess); |
324 | 323 |
325 bool silentInputs = inputsAreSilent(); | 324 bool silentInputs = inputsAreSilent(); |
326 if (!silentInputs) | 325 if (!silentInputs) { |
327 m_lastNonSilentTime = | 326 m_lastNonSilentTime = |
328 (context()->currentSampleFrame() + framesToProcess) / | 327 (context()->currentSampleFrame() + framesToProcess) / |
329 static_cast<double>(m_sampleRate); | 328 static_cast<double>(context()->sampleRate()); |
| 329 } |
330 | 330 |
331 if (silentInputs && propagatesSilence()) { | 331 if (silentInputs && propagatesSilence()) { |
332 silenceOutputs(); | 332 silenceOutputs(); |
333 // AudioParams still need to be processed so that the value can be updated | 333 // AudioParams still need to be processed so that the value can be updated |
334 // if there are automations or so that the upstream nodes get pulled if | 334 // if there are automations or so that the upstream nodes get pulled if |
335 // any are connected to the AudioParam. | 335 // any are connected to the AudioParam. |
336 processOnlyAudioParams(framesToProcess); | 336 processOnlyAudioParams(framesToProcess); |
337 } else { | 337 } else { |
338 // Unsilence the outputs first because the processing of the node may | 338 // Unsilence the outputs first because the processing of the node may |
339 // cause the outputs to go silent and we want to propagate that hint to | 339 // cause the outputs to go silent and we want to propagate that hint to |
(...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
952 } | 952 } |
953 | 953 |
954 void AudioNode::didAddOutput(unsigned numberOfOutputs) { | 954 void AudioNode::didAddOutput(unsigned numberOfOutputs) { |
955 m_connectedNodes.push_back(nullptr); | 955 m_connectedNodes.push_back(nullptr); |
956 DCHECK_EQ(numberOfOutputs, m_connectedNodes.size()); | 956 DCHECK_EQ(numberOfOutputs, m_connectedNodes.size()); |
957 m_connectedParams.push_back(nullptr); | 957 m_connectedParams.push_back(nullptr); |
958 DCHECK_EQ(numberOfOutputs, m_connectedParams.size()); | 958 DCHECK_EQ(numberOfOutputs, m_connectedParams.size()); |
959 } | 959 } |
960 | 960 |
961 } // namespace blink | 961 } // namespace blink |
OLD | NEW |