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

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

Issue 2501863003: Support for AudioContextOptions latencyHint. (Closed)
Patch Set: Updates based on reviewer comments. 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) 2011, Google Inc. All rights reserved. 2 * Copyright (C) 2011, 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 13 matching lines...) Expand all
24 */ 24 */
25 25
26 #include "modules/webaudio/DefaultAudioDestinationNode.h" 26 #include "modules/webaudio/DefaultAudioDestinationNode.h"
27 #include "bindings/core/v8/ExceptionMessages.h" 27 #include "bindings/core/v8/ExceptionMessages.h"
28 #include "bindings/core/v8/ExceptionState.h" 28 #include "bindings/core/v8/ExceptionState.h"
29 #include "core/dom/ExceptionCode.h" 29 #include "core/dom/ExceptionCode.h"
30 #include "modules/webaudio/BaseAudioContext.h" 30 #include "modules/webaudio/BaseAudioContext.h"
31 31
32 namespace blink { 32 namespace blink {
33 33
34 DefaultAudioDestinationHandler::DefaultAudioDestinationHandler(AudioNode& node) 34 DefaultAudioDestinationHandler::DefaultAudioDestinationHandler(
35 : AudioDestinationHandler(node, AudioDestination::hardwareSampleRate()), 35 AudioNode& node,
36 m_numberOfInputChannels(0) { 36 const WebAudioLatencyHint& latencyHint)
37 : AudioDestinationHandler(node),
38 m_numberOfInputChannels(0),
39 m_latencyHint(latencyHint) {
37 // Node-specific default mixing rules. 40 // Node-specific default mixing rules.
38 m_channelCount = 2; 41 m_channelCount = 2;
39 setInternalChannelCountMode(Explicit); 42 setInternalChannelCountMode(Explicit);
40 setInternalChannelInterpretation(AudioBus::Speakers); 43 setInternalChannelInterpretation(AudioBus::Speakers);
41 } 44 }
42 45
43 PassRefPtr<DefaultAudioDestinationHandler> 46 PassRefPtr<DefaultAudioDestinationHandler>
44 DefaultAudioDestinationHandler::create(AudioNode& node) { 47 DefaultAudioDestinationHandler::create(AudioNode& node,
45 return adoptRef(new DefaultAudioDestinationHandler(node)); 48 const WebAudioLatencyHint& latencyHint) {
49 return adoptRef(new DefaultAudioDestinationHandler(node, latencyHint));
46 } 50 }
47 51
48 DefaultAudioDestinationHandler::~DefaultAudioDestinationHandler() { 52 DefaultAudioDestinationHandler::~DefaultAudioDestinationHandler() {
49 DCHECK(!isInitialized()); 53 DCHECK(!isInitialized());
50 } 54 }
51 55
52 void DefaultAudioDestinationHandler::dispose() { 56 void DefaultAudioDestinationHandler::dispose() {
53 uninitialize(); 57 uninitialize();
54 AudioDestinationHandler::dispose(); 58 AudioDestinationHandler::dispose();
55 } 59 }
(...skipping 12 matching lines...) Expand all
68 if (!isInitialized()) 72 if (!isInitialized())
69 return; 73 return;
70 74
71 m_destination->stop(); 75 m_destination->stop();
72 m_numberOfInputChannels = 0; 76 m_numberOfInputChannels = 0;
73 77
74 AudioHandler::uninitialize(); 78 AudioHandler::uninitialize();
75 } 79 }
76 80
77 void DefaultAudioDestinationHandler::createDestination() { 81 void DefaultAudioDestinationHandler::createDestination() {
78 float hardwareSampleRate = AudioDestination::hardwareSampleRate();
79 VLOG(1) << ">>>> hardwareSampleRate = " << hardwareSampleRate;
80
81 m_destination = AudioDestination::create( 82 m_destination = AudioDestination::create(
82 *this, m_inputDeviceId, m_numberOfInputChannels, channelCount(), 83 *this, m_inputDeviceId, m_numberOfInputChannels, channelCount(),
83 hardwareSampleRate, context()->getSecurityOrigin()); 84 m_latencyHint, context()->getSecurityOrigin());
84 } 85 }
85 86
86 void DefaultAudioDestinationHandler::startRendering() { 87 void DefaultAudioDestinationHandler::startRendering() {
87 DCHECK(isInitialized()); 88 DCHECK(isInitialized());
88 if (isInitialized()) { 89 if (isInitialized()) {
89 DCHECK(!m_destination->isPlaying()); 90 DCHECK(!m_destination->isPlaying());
90 m_destination->start(); 91 m_destination->start();
91 } 92 }
92 } 93 }
93 94
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 127
127 if (!exceptionState.hadException() && 128 if (!exceptionState.hadException() &&
128 this->channelCount() != oldChannelCount && isInitialized()) { 129 this->channelCount() != oldChannelCount && isInitialized()) {
129 // Re-create destination. 130 // Re-create destination.
130 m_destination->stop(); 131 m_destination->stop();
131 createDestination(); 132 createDestination();
132 m_destination->start(); 133 m_destination->start();
133 } 134 }
134 } 135 }
135 136
137 double DefaultAudioDestinationHandler::sampleRate() const {
138 return m_destination ? m_destination->sampleRate() : 0;
o1ka 2016/12/02 12:02:13 How valid is the case when |m_destination| is null
139 }
140
141 int DefaultAudioDestinationHandler::framesPerBuffer() const {
142 return m_destination ? m_destination->framesPerBuffer() : 0;
143 }
144
136 // ---------------------------------------------------------------- 145 // ----------------------------------------------------------------
137 146
138 DefaultAudioDestinationNode::DefaultAudioDestinationNode( 147 DefaultAudioDestinationNode::DefaultAudioDestinationNode(
139 BaseAudioContext& context) 148 BaseAudioContext& context,
149 const WebAudioLatencyHint& latencyHint)
140 : AudioDestinationNode(context) { 150 : AudioDestinationNode(context) {
141 setHandler(DefaultAudioDestinationHandler::create(*this)); 151 setHandler(DefaultAudioDestinationHandler::create(*this, latencyHint));
142 } 152 }
143 153
144 DefaultAudioDestinationNode* DefaultAudioDestinationNode::create( 154 DefaultAudioDestinationNode* DefaultAudioDestinationNode::create(
145 BaseAudioContext* context) { 155 BaseAudioContext* context,
146 return new DefaultAudioDestinationNode(*context); 156 const WebAudioLatencyHint& latencyHint) {
157 return new DefaultAudioDestinationNode(*context, latencyHint);
147 } 158 }
148 159
149 } // namespace blink 160 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698