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

Side by Side Diff: third_party/WebKit/Source/platform/audio/AudioDSPKernelProcessor.cpp

Issue 2803733002: Convert ASSERT(foo) to DCHECK(foo) in platform/audio (Closed)
Patch Set: Mechanical change from ASSERT(foo) to DCHECK(foo) Created 3 years, 8 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 are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 26 matching lines...) Expand all
37 // "initialized" state. 37 // "initialized" state.
38 AudioDSPKernelProcessor::AudioDSPKernelProcessor(float sampleRate, 38 AudioDSPKernelProcessor::AudioDSPKernelProcessor(float sampleRate,
39 unsigned numberOfChannels) 39 unsigned numberOfChannels)
40 : AudioProcessor(sampleRate, numberOfChannels), m_hasJustReset(true) {} 40 : AudioProcessor(sampleRate, numberOfChannels), m_hasJustReset(true) {}
41 41
42 void AudioDSPKernelProcessor::initialize() { 42 void AudioDSPKernelProcessor::initialize() {
43 if (isInitialized()) 43 if (isInitialized())
44 return; 44 return;
45 45
46 MutexLocker locker(m_processLock); 46 MutexLocker locker(m_processLock);
47 ASSERT(!m_kernels.size()); 47 DCHECK(!m_kernels.size());
48 48
49 // Create processing kernels, one per channel. 49 // Create processing kernels, one per channel.
50 for (unsigned i = 0; i < numberOfChannels(); ++i) 50 for (unsigned i = 0; i < numberOfChannels(); ++i)
51 m_kernels.push_back(createKernel()); 51 m_kernels.push_back(createKernel());
52 52
53 m_initialized = true; 53 m_initialized = true;
54 m_hasJustReset = true; 54 m_hasJustReset = true;
55 } 55 }
56 56
57 void AudioDSPKernelProcessor::uninitialize() { 57 void AudioDSPKernelProcessor::uninitialize() {
(...skipping 16 matching lines...) Expand all
74 if (!isInitialized()) { 74 if (!isInitialized()) {
75 destination->zero(); 75 destination->zero();
76 return; 76 return;
77 } 77 }
78 78
79 MutexTryLocker tryLocker(m_processLock); 79 MutexTryLocker tryLocker(m_processLock);
80 if (tryLocker.locked()) { 80 if (tryLocker.locked()) {
81 bool channelCountMatches = 81 bool channelCountMatches =
82 source->numberOfChannels() == destination->numberOfChannels() && 82 source->numberOfChannels() == destination->numberOfChannels() &&
83 source->numberOfChannels() == m_kernels.size(); 83 source->numberOfChannels() == m_kernels.size();
84 ASSERT(channelCountMatches); 84 DCHECK(channelCountMatches);
85 if (!channelCountMatches) 85 if (!channelCountMatches)
86 return; 86 return;
87 87
88 for (unsigned i = 0; i < m_kernels.size(); ++i) 88 for (unsigned i = 0; i < m_kernels.size(); ++i)
89 m_kernels[i]->process(source->channel(i)->data(), 89 m_kernels[i]->process(source->channel(i)->data(),
90 destination->channel(i)->mutableData(), 90 destination->channel(i)->mutableData(),
91 framesToProcess); 91 framesToProcess);
92 } else { 92 } else {
93 // Unfortunately, the kernel is being processed by another thread. 93 // Unfortunately, the kernel is being processed by another thread.
94 // See also ConvolverNode::process(). 94 // See also ConvolverNode::process().
(...skipping 10 matching lines...) Expand all
105 // other thread is updating the kernels, so we'll have to skip it 105 // other thread is updating the kernels, so we'll have to skip it
106 // this time. 106 // this time.
107 if (tryLocker.locked()) { 107 if (tryLocker.locked()) {
108 for (unsigned i = 0; i < m_kernels.size(); ++i) 108 for (unsigned i = 0; i < m_kernels.size(); ++i)
109 m_kernels[i]->processOnlyAudioParams(framesToProcess); 109 m_kernels[i]->processOnlyAudioParams(framesToProcess);
110 } 110 }
111 } 111 }
112 112
113 // Resets filter state 113 // Resets filter state
114 void AudioDSPKernelProcessor::reset() { 114 void AudioDSPKernelProcessor::reset() {
115 ASSERT(isMainThread()); 115 DCHECK(isMainThread());
116 if (!isInitialized()) 116 if (!isInitialized())
117 return; 117 return;
118 118
119 // Forces snap to parameter values - first time. 119 // Forces snap to parameter values - first time.
120 // Any processing depending on this value must set it to false at the 120 // Any processing depending on this value must set it to false at the
121 // appropriate time. 121 // appropriate time.
122 m_hasJustReset = true; 122 m_hasJustReset = true;
123 123
124 MutexLocker locker(m_processLock); 124 MutexLocker locker(m_processLock);
125 for (unsigned i = 0; i < m_kernels.size(); ++i) 125 for (unsigned i = 0; i < m_kernels.size(); ++i)
126 m_kernels[i]->reset(); 126 m_kernels[i]->reset();
127 } 127 }
128 128
129 void AudioDSPKernelProcessor::setNumberOfChannels(unsigned numberOfChannels) { 129 void AudioDSPKernelProcessor::setNumberOfChannels(unsigned numberOfChannels) {
130 if (numberOfChannels == m_numberOfChannels) 130 if (numberOfChannels == m_numberOfChannels)
131 return; 131 return;
132 132
133 ASSERT(!isInitialized()); 133 DCHECK(!isInitialized());
134 if (!isInitialized()) 134 if (!isInitialized())
135 m_numberOfChannels = numberOfChannels; 135 m_numberOfChannels = numberOfChannels;
136 } 136 }
137 137
138 double AudioDSPKernelProcessor::tailTime() const { 138 double AudioDSPKernelProcessor::tailTime() const {
139 ASSERT(!isMainThread()); 139 DCHECK(!isMainThread());
140 MutexTryLocker tryLocker(m_processLock); 140 MutexTryLocker tryLocker(m_processLock);
141 if (tryLocker.locked()) { 141 if (tryLocker.locked()) {
142 // It is expected that all the kernels have the same tailTime. 142 // It is expected that all the kernels have the same tailTime.
143 return !m_kernels.isEmpty() ? m_kernels.front()->tailTime() : 0; 143 return !m_kernels.isEmpty() ? m_kernels.front()->tailTime() : 0;
144 } 144 }
145 // Since we don't want to block the Audio Device thread, we return a large 145 // Since we don't want to block the Audio Device thread, we return a large
146 // value instead of trying to acquire the lock. 146 // value instead of trying to acquire the lock.
147 return std::numeric_limits<double>::infinity(); 147 return std::numeric_limits<double>::infinity();
148 } 148 }
149 149
150 double AudioDSPKernelProcessor::latencyTime() const { 150 double AudioDSPKernelProcessor::latencyTime() const {
151 ASSERT(!isMainThread()); 151 DCHECK(!isMainThread());
152 MutexTryLocker tryLocker(m_processLock); 152 MutexTryLocker tryLocker(m_processLock);
153 if (tryLocker.locked()) { 153 if (tryLocker.locked()) {
154 // It is expected that all the kernels have the same latencyTime. 154 // It is expected that all the kernels have the same latencyTime.
155 return !m_kernels.isEmpty() ? m_kernels.front()->latencyTime() : 0; 155 return !m_kernels.isEmpty() ? m_kernels.front()->latencyTime() : 0;
156 } 156 }
157 // Since we don't want to block the Audio Device thread, we return a large 157 // Since we don't want to block the Audio Device thread, we return a large
158 // value instead of trying to acquire the lock. 158 // value instead of trying to acquire the lock.
159 return std::numeric_limits<double>::infinity(); 159 return std::numeric_limits<double>::infinity();
160 } 160 }
161 161
162 } // namespace blink 162 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698