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

Side by Side Diff: third_party/WebKit/Source/modules/webaudio/BaseAudioContext.h

Issue 2501863003: Support for AudioContextOptions latencyHint. (Closed)
Patch Set: Check all LatencyHints WebAudioDeviceImpl test. 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 * 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 #include "wtf/Threading.h" 45 #include "wtf/Threading.h"
46 #include "wtf/Vector.h" 46 #include "wtf/Vector.h"
47 #include "wtf/build_config.h" 47 #include "wtf/build_config.h"
48 48
49 namespace blink { 49 namespace blink {
50 50
51 class AnalyserNode; 51 class AnalyserNode;
52 class AudioBuffer; 52 class AudioBuffer;
53 class AudioBufferCallback; 53 class AudioBufferCallback;
54 class AudioBufferSourceNode; 54 class AudioBufferSourceNode;
55 class AudioContextOptions;
55 class AudioListener; 56 class AudioListener;
56 class BaseAudioContextTest; 57 class BaseAudioContextTest;
57 class BiquadFilterNode; 58 class BiquadFilterNode;
58 class ChannelMergerNode; 59 class ChannelMergerNode;
59 class ChannelSplitterNode; 60 class ChannelSplitterNode;
60 class ConstantSourceNode; 61 class ConstantSourceNode;
61 class ConvolverNode; 62 class ConvolverNode;
62 class DelayNode; 63 class DelayNode;
63 class Document; 64 class Document;
64 class DynamicsCompressorNode; 65 class DynamicsCompressorNode;
(...skipping 28 matching lines...) Expand all
93 94
94 public: 95 public:
95 // The state of an audio context. On creation, the state is Suspended. The 96 // The state of an audio context. On creation, the state is Suspended. The
96 // state is Running if audio is being processed (audio graph is being pulled 97 // state is Running if audio is being processed (audio graph is being pulled
97 // for data). The state is Closed if the audio context has been closed. The 98 // for data). The state is Closed if the audio context has been closed. The
98 // valid transitions are from Suspended to either Running or Closed; Running 99 // valid transitions are from Suspended to either Running or Closed; Running
99 // to Suspended or Closed. Once Closed, there are no valid transitions. 100 // to Suspended or Closed. Once Closed, there are no valid transitions.
100 enum AudioContextState { Suspended, Running, Closed }; 101 enum AudioContextState { Suspended, Running, Closed };
101 102
102 // Create an AudioContext for rendering to the audio hardware. 103 // Create an AudioContext for rendering to the audio hardware.
103 static BaseAudioContext* create(Document&, ExceptionState&); 104 static BaseAudioContext* create(Document&,
105 const AudioContextOptions&,
106 ExceptionState&);
104 107
105 ~BaseAudioContext() override; 108 ~BaseAudioContext() override;
106 109
107 DECLARE_VIRTUAL_TRACE(); 110 DECLARE_VIRTUAL_TRACE();
108 111
109 // Is the destination node initialized and ready to handle audio? 112 // Is the destination node initialized and ready to handle audio?
110 bool isDestinationInitialized() const { 113 bool isDestinationInitialized() const {
111 AudioDestinationNode* dest = destination(); 114 AudioDestinationNode* dest = destination();
112 return dest ? dest->audioDestinationHandler().isInitialized() : false; 115 return dest ? dest->audioDestinationHandler().isInitialized() : false;
113 } 116 }
(...skipping 16 matching lines...) Expand all
130 133
131 double currentTime() const { 134 double currentTime() const {
132 // TODO: What is the correct value for the current time if the destination 135 // TODO: What is the correct value for the current time if the destination
133 // node has gone away? 0 is a valid time. 136 // node has gone away? 0 is a valid time.
134 return m_destinationNode 137 return m_destinationNode
135 ? m_destinationNode->audioDestinationHandler().currentTime() 138 ? m_destinationNode->audioDestinationHandler().currentTime()
136 : 0; 139 : 0;
137 } 140 }
138 141
139 float sampleRate() const { 142 float sampleRate() const {
140 return m_destinationNode ? m_destinationNode->handler().sampleRate() : 0; 143 return m_destinationNode
144 ? m_destinationNode->audioDestinationHandler().sampleRate()
145 : closedContextSampleRate();
146 }
147
148 float framesPerBuffer() const {
149 return m_destinationNode
150 ? m_destinationNode->audioDestinationHandler().framesPerBuffer()
151 : 0;
141 } 152 }
142 153
143 String state() const; 154 String state() const;
144 AudioContextState contextState() const { return m_contextState; } 155 AudioContextState contextState() const { return m_contextState; }
145 void throwExceptionForClosedState(ExceptionState&); 156 void throwExceptionForClosedState(ExceptionState&);
146 157
147 AudioBuffer* createBuffer(unsigned numberOfChannels, 158 AudioBuffer* createBuffer(unsigned numberOfChannels,
148 size_t numberOfFrames, 159 size_t numberOfFrames,
149 float sampleRate, 160 float sampleRate,
150 ExceptionState&); 161 ExceptionState&);
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 // This is considering 32 is large enough for multiple channels audio. 458 // This is considering 32 is large enough for multiple channels audio.
448 // It is somewhat arbitrary and could be increased if necessary. 459 // It is somewhat arbitrary and could be increased if necessary.
449 enum { MaxNumberOfChannels = 32 }; 460 enum { MaxNumberOfChannels = 32 };
450 461
451 Optional<AutoplayStatus> m_autoplayStatus; 462 Optional<AutoplayStatus> m_autoplayStatus;
452 }; 463 };
453 464
454 } // namespace blink 465 } // namespace blink
455 466
456 #endif // BaseAudioContext_h 467 #endif // BaseAudioContext_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698