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

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

Issue 2359553003: Replaced PassRefPtr copies with moves. (Closed)
Patch Set: Created 4 years, 3 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 * 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 30 matching lines...) Expand all
41 41
42 // Buffer size at which the web audio engine will render. 42 // Buffer size at which the web audio engine will render.
43 const unsigned renderBufferSize = 128; 43 const unsigned renderBufferSize = 128;
44 44
45 // Size of the FIFO 45 // Size of the FIFO
46 const size_t fifoSize = 8192; 46 const size_t fifoSize = 8192;
47 47
48 // Factory method: Chromium-implementation 48 // Factory method: Chromium-implementation
49 std::unique_ptr<AudioDestination> AudioDestination::create(AudioIOCallback& call back, const String& inputDeviceId, unsigned numberOfInputChannels, unsigned numb erOfOutputChannels, float sampleRate, PassRefPtr<SecurityOrigin> securityOrigin) 49 std::unique_ptr<AudioDestination> AudioDestination::create(AudioIOCallback& call back, const String& inputDeviceId, unsigned numberOfInputChannels, unsigned numb erOfOutputChannels, float sampleRate, PassRefPtr<SecurityOrigin> securityOrigin)
50 { 50 {
51 return wrapUnique(new AudioDestination(callback, inputDeviceId, numberOfInpu tChannels, numberOfOutputChannels, sampleRate, securityOrigin)); 51 return wrapUnique(new AudioDestination(callback, inputDeviceId, numberOfInpu tChannels, numberOfOutputChannels, sampleRate, std::move(securityOrigin)));
52 } 52 }
53 53
54 AudioDestination::AudioDestination(AudioIOCallback& callback, const String& inpu tDeviceId, unsigned numberOfInputChannels, unsigned numberOfOutputChannels, floa t sampleRate, PassRefPtr<SecurityOrigin> securityOrigin) 54 AudioDestination::AudioDestination(AudioIOCallback& callback, const String& inpu tDeviceId, unsigned numberOfInputChannels, unsigned numberOfOutputChannels, floa t sampleRate, PassRefPtr<SecurityOrigin> securityOrigin)
55 : m_callback(callback) 55 : m_callback(callback)
56 , m_numberOfOutputChannels(numberOfOutputChannels) 56 , m_numberOfOutputChannels(numberOfOutputChannels)
57 , m_inputBus(AudioBus::create(numberOfInputChannels, renderBufferSize)) 57 , m_inputBus(AudioBus::create(numberOfInputChannels, renderBufferSize))
58 , m_renderBus(AudioBus::create(numberOfOutputChannels, renderBufferSize, fal se)) 58 , m_renderBus(AudioBus::create(numberOfOutputChannels, renderBufferSize, fal se))
59 , m_sampleRate(sampleRate) 59 , m_sampleRate(sampleRate)
60 , m_isPlaying(false) 60 , m_isPlaying(false)
61 { 61 {
(...skipping 23 matching lines...) Expand all
85 85
86 if (m_callbackBufferSize <= kSmallBufferSize) 86 if (m_callbackBufferSize <= kSmallBufferSize)
87 m_callbackBufferSize = kDefaultCallbackBufferSize; 87 m_callbackBufferSize = kDefaultCallbackBufferSize;
88 #endif 88 #endif
89 89
90 // Quick exit if the requested size is too large. 90 // Quick exit if the requested size is too large.
91 ASSERT(m_callbackBufferSize + renderBufferSize <= fifoSize); 91 ASSERT(m_callbackBufferSize + renderBufferSize <= fifoSize);
92 if (m_callbackBufferSize + renderBufferSize > fifoSize) 92 if (m_callbackBufferSize + renderBufferSize > fifoSize)
93 return; 93 return;
94 94
95 m_audioDevice = wrapUnique(Platform::current()->createAudioDevice(m_callback BufferSize, numberOfInputChannels, numberOfOutputChannels, sampleRate, this, inp utDeviceId, securityOrigin)); 95 m_audioDevice = wrapUnique(Platform::current()->createAudioDevice(m_callback BufferSize, numberOfInputChannels, numberOfOutputChannels, sampleRate, this, inp utDeviceId, std::move(securityOrigin)));
96 ASSERT(m_audioDevice); 96 ASSERT(m_audioDevice);
97 97
98 // Record the sizes if we successfully created an output device. 98 // Record the sizes if we successfully created an output device.
99 hardwareBufferSizeHistogram.sample(recommendedHardwareBufferSize); 99 hardwareBufferSizeHistogram.sample(recommendedHardwareBufferSize);
100 callbackBufferSizeHistogram.sample(m_callbackBufferSize); 100 callbackBufferSizeHistogram.sample(m_callbackBufferSize);
101 101
102 // Create a FIFO to handle the possibility of the callback size 102 // Create a FIFO to handle the possibility of the callback size
103 // not being a multiple of the render size. If the FIFO already 103 // not being a multiple of the render size. If the FIFO already
104 // contains enough data, the data will be provided directly. 104 // contains enough data, the data will be provided directly.
105 // Otherwise, the FIFO will call the provider enough times to 105 // Otherwise, the FIFO will call the provider enough times to
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 AudioBus* sourceBus = nullptr; 183 AudioBus* sourceBus = nullptr;
184 if (m_inputFifo->framesInFifo() >= framesToProcess) { 184 if (m_inputFifo->framesInFifo() >= framesToProcess) {
185 m_inputFifo->consume(m_inputBus.get(), framesToProcess); 185 m_inputFifo->consume(m_inputBus.get(), framesToProcess);
186 sourceBus = m_inputBus.get(); 186 sourceBus = m_inputBus.get();
187 } 187 }
188 188
189 m_callback.render(sourceBus, bus, framesToProcess); 189 m_callback.render(sourceBus, bus, framesToProcess);
190 } 190 }
191 191
192 } // namespace blink 192 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/Length.cpp ('k') | third_party/WebKit/Source/platform/blob/BlobRegistry.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698