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

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

Issue 2547053003: s/ passed(...) / WTF::passed(...) / to avoid future ambiguity w/ base::Passed. (Closed)
Patch Set: Rebasing... Created 4 years 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 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 const size_t fifoSize = 8192; 44 const size_t fifoSize = 8192;
45 45
46 // Factory method: Chromium-implementation 46 // Factory method: Chromium-implementation
47 std::unique_ptr<AudioDestination> AudioDestination::create( 47 std::unique_ptr<AudioDestination> AudioDestination::create(
48 AudioIOCallback& callback, 48 AudioIOCallback& callback,
49 const String& inputDeviceId, 49 const String& inputDeviceId,
50 unsigned numberOfInputChannels, 50 unsigned numberOfInputChannels,
51 unsigned numberOfOutputChannels, 51 unsigned numberOfOutputChannels,
52 float sampleRate, 52 float sampleRate,
53 PassRefPtr<SecurityOrigin> securityOrigin) { 53 PassRefPtr<SecurityOrigin> securityOrigin) {
54 return wrapUnique(new AudioDestination( 54 return WTF::wrapUnique(new AudioDestination(
55 callback, inputDeviceId, numberOfInputChannels, numberOfOutputChannels, 55 callback, inputDeviceId, numberOfInputChannels, numberOfOutputChannels,
56 sampleRate, std::move(securityOrigin))); 56 sampleRate, std::move(securityOrigin)));
57 } 57 }
58 58
59 AudioDestination::AudioDestination(AudioIOCallback& callback, 59 AudioDestination::AudioDestination(AudioIOCallback& callback,
60 const String& inputDeviceId, 60 const String& inputDeviceId,
61 unsigned numberOfInputChannels, 61 unsigned numberOfInputChannels,
62 unsigned numberOfOutputChannels, 62 unsigned numberOfOutputChannels,
63 float sampleRate, 63 float sampleRate,
64 PassRefPtr<SecurityOrigin> securityOrigin) 64 PassRefPtr<SecurityOrigin> securityOrigin)
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 if (m_callbackBufferSize <= kSmallBufferSize) 101 if (m_callbackBufferSize <= kSmallBufferSize)
102 m_callbackBufferSize = kDefaultCallbackBufferSize; 102 m_callbackBufferSize = kDefaultCallbackBufferSize;
103 #endif 103 #endif
104 104
105 // Quick exit if the requested size is too large. 105 // Quick exit if the requested size is too large.
106 DCHECK_LE(m_callbackBufferSize + AudioUtilities::kRenderQuantumFrames, 106 DCHECK_LE(m_callbackBufferSize + AudioUtilities::kRenderQuantumFrames,
107 fifoSize); 107 fifoSize);
108 if (m_callbackBufferSize + AudioUtilities::kRenderQuantumFrames > fifoSize) 108 if (m_callbackBufferSize + AudioUtilities::kRenderQuantumFrames > fifoSize)
109 return; 109 return;
110 110
111 m_audioDevice = wrapUnique(Platform::current()->createAudioDevice( 111 m_audioDevice = WTF::wrapUnique(Platform::current()->createAudioDevice(
112 m_callbackBufferSize, numberOfInputChannels, numberOfOutputChannels, 112 m_callbackBufferSize, numberOfInputChannels, numberOfOutputChannels,
113 sampleRate, this, inputDeviceId, std::move(securityOrigin))); 113 sampleRate, this, inputDeviceId, std::move(securityOrigin)));
114 ASSERT(m_audioDevice); 114 ASSERT(m_audioDevice);
115 115
116 // Record the sizes if we successfully created an output device. 116 // Record the sizes if we successfully created an output device.
117 hardwareBufferSizeHistogram.sample(recommendedHardwareBufferSize); 117 hardwareBufferSizeHistogram.sample(recommendedHardwareBufferSize);
118 callbackBufferSizeHistogram.sample(m_callbackBufferSize); 118 callbackBufferSizeHistogram.sample(m_callbackBufferSize);
119 119
120 // Create a FIFO to handle the possibility of the callback size 120 // Create a FIFO to handle the possibility of the callback size
121 // not being a multiple of the render size. If the FIFO already 121 // not being a multiple of the render size. If the FIFO already
122 // contains enough data, the data will be provided directly. 122 // contains enough data, the data will be provided directly.
123 // Otherwise, the FIFO will call the provider enough times to 123 // Otherwise, the FIFO will call the provider enough times to
124 // satisfy the request for data. 124 // satisfy the request for data.
125 m_fifo = wrapUnique(new AudioPullFIFO(*this, numberOfOutputChannels, fifoSize, 125 m_fifo =
126 WTF::wrapUnique(new AudioPullFIFO(*this, numberOfOutputChannels, fifoSize,
126 AudioUtilities::kRenderQuantumFrames)); 127 AudioUtilities::kRenderQuantumFrames));
127 128
128 // Input buffering. 129 // Input buffering.
129 m_inputFifo = makeUnique<AudioFIFO>(numberOfInputChannels, fifoSize); 130 m_inputFifo = WTF::makeUnique<AudioFIFO>(numberOfInputChannels, fifoSize);
130 131
131 // If the callback size does not match the render size, then we need to 132 // If the callback size does not match the render size, then we need to
132 // buffer some extra silence for the input. Otherwise, we can over-consume 133 // buffer some extra silence for the input. Otherwise, we can over-consume
133 // the input FIFO. 134 // the input FIFO.
134 if (m_callbackBufferSize != AudioUtilities::kRenderQuantumFrames) { 135 if (m_callbackBufferSize != AudioUtilities::kRenderQuantumFrames) {
135 // FIXME: handle multi-channel input and don't hard-code to stereo. 136 // FIXME: handle multi-channel input and don't hard-code to stereo.
136 RefPtr<AudioBus> silence = 137 RefPtr<AudioBus> silence =
137 AudioBus::create(2, AudioUtilities::kRenderQuantumFrames); 138 AudioBus::create(2, AudioUtilities::kRenderQuantumFrames);
138 m_inputFifo->push(silence.get()); 139 m_inputFifo->push(silence.get());
139 } 140 }
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 AudioBus* sourceBus = nullptr; 200 AudioBus* sourceBus = nullptr;
200 if (m_inputFifo->framesInFifo() >= framesToProcess) { 201 if (m_inputFifo->framesInFifo() >= framesToProcess) {
201 m_inputFifo->consume(m_inputBus.get(), framesToProcess); 202 m_inputFifo->consume(m_inputBus.get(), framesToProcess);
202 sourceBus = m_inputBus.get(); 203 sourceBus = m_inputBus.get();
203 } 204 }
204 205
205 m_callback.render(sourceBus, bus, framesToProcess); 206 m_callback.render(sourceBus, bus, framesToProcess);
206 } 207 }
207 208
208 } // namespace blink 209 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/audio/AudioChannel.h ('k') | third_party/WebKit/Source/platform/audio/AudioResampler.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698