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

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

Issue 2793593002: AudioWorklet prototype
Patch Set: Merge changes, AudioParam bug fix Created 3 years, 5 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) 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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 81
82 void DefaultAudioDestinationHandler::CreateDestination() { 82 void DefaultAudioDestinationHandler::CreateDestination() {
83 destination_ = AudioDestination::Create(*this, ChannelCount(), latency_hint_, 83 destination_ = AudioDestination::Create(*this, ChannelCount(), latency_hint_,
84 Context()->GetSecurityOrigin()); 84 Context()->GetSecurityOrigin());
85 } 85 }
86 86
87 void DefaultAudioDestinationHandler::StartRendering() { 87 void DefaultAudioDestinationHandler::StartRendering() {
88 DCHECK(IsInitialized()); 88 DCHECK(IsInitialized());
89 if (IsInitialized()) { 89 if (IsInitialized()) {
90 DCHECK(!destination_->IsPlaying()); 90 DCHECK(!destination_->IsPlaying());
91 destination_->Start(); 91 destination_->Start(Context()->GetRenderingThread());
92 } 92 }
93 } 93 }
94 94
95 void DefaultAudioDestinationHandler::StopRendering() { 95 void DefaultAudioDestinationHandler::StopRendering() {
96 DCHECK(IsInitialized()); 96 DCHECK(IsInitialized());
97 if (IsInitialized()) { 97 if (IsInitialized()) {
98 DCHECK(destination_->IsPlaying()); 98 DCHECK(destination_->IsPlaying());
99 destination_->Stop(); 99 destination_->Stop();
100 } 100 }
101 } 101 }
(...skipping 26 matching lines...) Expand all
128 } 128 }
129 129
130 unsigned long old_channel_count = this->ChannelCount(); 130 unsigned long old_channel_count = this->ChannelCount();
131 AudioHandler::SetChannelCount(channel_count, exception_state); 131 AudioHandler::SetChannelCount(channel_count, exception_state);
132 132
133 if (!exception_state.HadException() && 133 if (!exception_state.HadException() &&
134 this->ChannelCount() != old_channel_count && IsInitialized()) { 134 this->ChannelCount() != old_channel_count && IsInitialized()) {
135 // Re-create destination. 135 // Re-create destination.
136 destination_->Stop(); 136 destination_->Stop();
137 CreateDestination(); 137 CreateDestination();
138 destination_->Start(); 138 destination_->Start(Context()->GetRenderingThread());
139 } 139 }
140 } 140 }
141 141
142 double DefaultAudioDestinationHandler::SampleRate() const { 142 double DefaultAudioDestinationHandler::SampleRate() const {
143 return destination_ ? destination_->SampleRate() : 0; 143 return destination_ ? destination_->SampleRate() : 0;
144 } 144 }
145 145
146 int DefaultAudioDestinationHandler::FramesPerBuffer() const { 146 int DefaultAudioDestinationHandler::FramesPerBuffer() const {
147 return destination_ ? destination_->FramesPerBuffer() : 0; 147 return destination_ ? destination_->FramesPerBuffer() : 0;
148 } 148 }
149 149
150 // ---------------------------------------------------------------- 150 // ----------------------------------------------------------------
151 151
152 DefaultAudioDestinationNode::DefaultAudioDestinationNode( 152 DefaultAudioDestinationNode::DefaultAudioDestinationNode(
153 BaseAudioContext& context, 153 BaseAudioContext& context,
154 const WebAudioLatencyHint& latency_hint) 154 const WebAudioLatencyHint& latency_hint)
155 : AudioDestinationNode(context) { 155 : AudioDestinationNode(context) {
156 SetHandler(DefaultAudioDestinationHandler::Create(*this, latency_hint)); 156 SetHandler(DefaultAudioDestinationHandler::Create(*this, latency_hint));
157 } 157 }
158 158
159 DefaultAudioDestinationNode* DefaultAudioDestinationNode::Create( 159 DefaultAudioDestinationNode* DefaultAudioDestinationNode::Create(
160 BaseAudioContext* context, 160 BaseAudioContext* context,
161 const WebAudioLatencyHint& latency_hint) { 161 const WebAudioLatencyHint& latency_hint) {
162 return new DefaultAudioDestinationNode(*context, latency_hint); 162 return new DefaultAudioDestinationNode(*context, latency_hint);
163 } 163 }
164 164
165 } // namespace blink 165 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698