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

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

Issue 2750543003: Support AudioContextOptions latencyHint as double. (Closed)
Patch Set: Created 3 years, 9 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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 m_isPlaying(false), 66 m_isPlaying(false),
67 m_callback(callback), 67 m_callback(callback),
68 m_outputBus(AudioBus::create(numberOfOutputChannels, 68 m_outputBus(AudioBus::create(numberOfOutputChannels,
69 AudioUtilities::kRenderQuantumFrames, 69 AudioUtilities::kRenderQuantumFrames,
70 false)), 70 false)),
71 m_renderBus(AudioBus::create(numberOfOutputChannels, 71 m_renderBus(AudioBus::create(numberOfOutputChannels,
72 AudioUtilities::kRenderQuantumFrames)), 72 AudioUtilities::kRenderQuantumFrames)),
73 m_fifo( 73 m_fifo(
74 WTF::wrapUnique(new PushPullFIFO(numberOfOutputChannels, kFIFOSize))), 74 WTF::wrapUnique(new PushPullFIFO(numberOfOutputChannels, kFIFOSize))),
75 m_framesElapsed(0) { 75 m_framesElapsed(0) {
76 m_callbackBufferSize = hardwareBufferSize();
77 if (!checkBufferSize()) {
78 NOTREACHED();
79 }
80
81 // Create WebAudioDevice. blink::WebAudioDevice is designed to support the 76 // Create WebAudioDevice. blink::WebAudioDevice is designed to support the
82 // local input (e.g. loopback from OS audio system), but Chromium's media 77 // local input (e.g. loopback from OS audio system), but Chromium's media
83 // renderer does not support it currently. Thus, we use zero for the number 78 // renderer does not support it currently. Thus, we use zero for the number
84 // of input channels. 79 // of input channels.
85 m_webAudioDevice = WTF::wrapUnique(Platform::current()->createAudioDevice( 80 m_webAudioDevice = WTF::wrapUnique(Platform::current()->createAudioDevice(
86 0, numberOfOutputChannels, latencyHint, this, String(), 81 0, numberOfOutputChannels, latencyHint, this, String(),
87 std::move(securityOrigin))); 82 std::move(securityOrigin)));
88 DCHECK(m_webAudioDevice); 83 DCHECK(m_webAudioDevice);
84
85 m_callbackBufferSize = m_webAudioDevice->framesPerBuffer();
Andrew MacPherson 2017/03/14 12:03:03 This CL changed m_callbackBufferSize to hardwareBu
hongchan 2017/03/14 14:36:34 If you rebase the patch, you'll see this is fixed.
Andrew MacPherson 2017/03/15 15:08:18 Great, just rebased now and can see this, thanks!
86 if (!checkBufferSize()) {
87 NOTREACHED();
88 }
89 } 89 }
90 90
91 AudioDestination::~AudioDestination() { 91 AudioDestination::~AudioDestination() {
92 stop(); 92 stop();
93 } 93 }
94 94
95 void AudioDestination::render(const WebVector<float*>& destinationData, 95 void AudioDestination::render(const WebVector<float*>& destinationData,
96 size_t numberOfFrames, 96 size_t numberOfFrames,
97 double delay, 97 double delay,
98 double delayTimestamp, 98 double delayTimestamp,
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 callbackBufferSizeHistogram.sample(m_callbackBufferSize); 198 callbackBufferSizeHistogram.sample(m_callbackBufferSize);
199 199
200 // Check if the requested buffer size is too large. 200 // Check if the requested buffer size is too large.
201 bool isBufferSizeValid = 201 bool isBufferSizeValid =
202 m_callbackBufferSize + AudioUtilities::kRenderQuantumFrames <= kFIFOSize; 202 m_callbackBufferSize + AudioUtilities::kRenderQuantumFrames <= kFIFOSize;
203 DCHECK(isBufferSizeValid); 203 DCHECK(isBufferSizeValid);
204 return isBufferSizeValid; 204 return isBufferSizeValid;
205 } 205 }
206 206
207 } // namespace blink 207 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698