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

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

Issue 2159403002: Replace ASSERT with DCHECK in WebAudio (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 4 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) 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 23 matching lines...) Expand all
34 34
35 AudioDestinationHandler::AudioDestinationHandler(AudioNode& node, float sampleRa te) 35 AudioDestinationHandler::AudioDestinationHandler(AudioNode& node, float sampleRa te)
36 : AudioHandler(NodeTypeDestination, node, sampleRate) 36 : AudioHandler(NodeTypeDestination, node, sampleRate)
37 , m_currentSampleFrame(0) 37 , m_currentSampleFrame(0)
38 { 38 {
39 addInput(); 39 addInput();
40 } 40 }
41 41
42 AudioDestinationHandler::~AudioDestinationHandler() 42 AudioDestinationHandler::~AudioDestinationHandler()
43 { 43 {
44 ASSERT(!isInitialized()); 44 DCHECK(!isInitialized());
45 } 45 }
46 46
47 void AudioDestinationHandler::render(AudioBus* sourceBus, AudioBus* destinationB us, size_t numberOfFrames) 47 void AudioDestinationHandler::render(AudioBus* sourceBus, AudioBus* destinationB us, size_t numberOfFrames)
48 { 48 {
49 // We don't want denormals slowing down any of the audio processing 49 // We don't want denormals slowing down any of the audio processing
50 // since they can very seriously hurt performance. 50 // since they can very seriously hurt performance.
51 // This will take care of all AudioNodes because they all process within thi s scope. 51 // This will take care of all AudioNodes because they all process within thi s scope.
52 DenormalDisabler denormalDisabler; 52 DenormalDisabler denormalDisabler;
53 53
54 // Need to check if the context actually alive. Otherwise the subsequent 54 // Need to check if the context actually alive. Otherwise the subsequent
55 // steps will fail. If the context is not alive somehow, return immediately 55 // steps will fail. If the context is not alive somehow, return immediately
56 // and do nothing. 56 // and do nothing.
57 // 57 //
58 // TODO(hongchan): because the context can go away while rendering, so this 58 // TODO(hongchan): because the context can go away while rendering, so this
59 // check cannot guarantee the safe execution of the following steps. 59 // check cannot guarantee the safe execution of the following steps.
60 ASSERT(context()); 60 DCHECK(context());
61 if (!context()) 61 if (!context())
62 return; 62 return;
63 63
64 context()->deferredTaskHandler().setAudioThreadToCurrentThread(); 64 context()->deferredTaskHandler().setAudioThreadToCurrentThread();
65 65
66 // If the destination node is not initialized, pass the silence to the final 66 // If the destination node is not initialized, pass the silence to the final
67 // audio destination (one step before the FIFO). This check is for the case 67 // audio destination (one step before the FIFO). This check is for the case
68 // where the destination is in the middle of tearing down process. 68 // where the destination is in the middle of tearing down process.
69 if (!isInitialized()) { 69 if (!isInitialized()) {
70 destinationBus->zero(); 70 destinationBus->zero();
71 return; 71 return;
72 } 72 }
73 73
74 // Let the context take care of any business at the start of each render qua ntum. 74 // Let the context take care of any business at the start of each render qua ntum.
75 context()->handlePreRenderTasks(); 75 context()->handlePreRenderTasks();
76 76
77 // Prepare the local audio input provider for this render quantum. 77 // Prepare the local audio input provider for this render quantum.
78 if (sourceBus) 78 if (sourceBus)
79 m_localAudioInputProvider.set(sourceBus); 79 m_localAudioInputProvider.set(sourceBus);
80 80
81 ASSERT(numberOfInputs() >= 1); 81 DCHECK_GE(numberOfInputs(), 1u);
82 if (numberOfInputs() < 1) { 82 if (numberOfInputs() < 1) {
83 destinationBus->zero(); 83 destinationBus->zero();
84 return; 84 return;
85 } 85 }
86 // This will cause the node(s) connected to us to process, which in turn wil l pull on their input(s), 86 // This will cause the node(s) connected to us to process, which in turn wil l pull on their input(s),
87 // all the way backwards through the rendering graph. 87 // all the way backwards through the rendering graph.
88 AudioBus* renderedBus = input(0).pull(destinationBus, numberOfFrames); 88 AudioBus* renderedBus = input(0).pull(destinationBus, numberOfFrames);
89 89
90 if (!renderedBus) { 90 if (!renderedBus) {
91 destinationBus->zero(); 91 destinationBus->zero();
(...skipping 25 matching lines...) Expand all
117 return static_cast<AudioDestinationHandler&>(handler()); 117 return static_cast<AudioDestinationHandler&>(handler());
118 } 118 }
119 119
120 unsigned long AudioDestinationNode::maxChannelCount() const 120 unsigned long AudioDestinationNode::maxChannelCount() const
121 { 121 {
122 return audioDestinationHandler().maxChannelCount(); 122 return audioDestinationHandler().maxChannelCount();
123 } 123 }
124 124
125 } // namespace blink 125 } // namespace blink
126 126
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698