OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/renderer/media/webaudiosourceprovider_impl.h" | 5 #include "content/renderer/media/webaudiosourceprovider_impl.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "third_party/WebKit/public/web/WebAudioSourceProviderClient.h" | 10 #include "third_party/WebKit/public/web/WebAudioSourceProviderClient.h" |
11 | 11 |
12 using WebKit::WebVector; | 12 using blink::WebVector; |
13 | 13 |
14 namespace content { | 14 namespace content { |
15 | 15 |
16 namespace { | 16 namespace { |
17 | 17 |
18 // Simple helper class for Try() locks. Lock is Try()'d on construction and | 18 // Simple helper class for Try() locks. Lock is Try()'d on construction and |
19 // must be checked via the locked() attribute. If acquisition was successful | 19 // must be checked via the locked() attribute. If acquisition was successful |
20 // the lock will be released upon destruction. | 20 // the lock will be released upon destruction. |
21 // TODO(dalecurtis): This should probably move to base/ if others start using | 21 // TODO(dalecurtis): This should probably move to base/ if others start using |
22 // this pattern. | 22 // this pattern. |
(...skipping 27 matching lines...) Expand all Loading... |
50 volume_(1.0), | 50 volume_(1.0), |
51 state_(kStopped), | 51 state_(kStopped), |
52 renderer_(NULL), | 52 renderer_(NULL), |
53 client_(NULL), | 53 client_(NULL), |
54 sink_(sink) { | 54 sink_(sink) { |
55 } | 55 } |
56 | 56 |
57 WebAudioSourceProviderImpl::~WebAudioSourceProviderImpl() {} | 57 WebAudioSourceProviderImpl::~WebAudioSourceProviderImpl() {} |
58 | 58 |
59 void WebAudioSourceProviderImpl::setClient( | 59 void WebAudioSourceProviderImpl::setClient( |
60 WebKit::WebAudioSourceProviderClient* client) { | 60 blink::WebAudioSourceProviderClient* client) { |
61 base::AutoLock auto_lock(sink_lock_); | 61 base::AutoLock auto_lock(sink_lock_); |
62 if (client && client != client_) { | 62 if (client && client != client_) { |
63 // Detach the audio renderer from normal playback. | 63 // Detach the audio renderer from normal playback. |
64 sink_->Stop(); | 64 sink_->Stop(); |
65 | 65 |
66 // The client will now take control by calling provideInput() periodically. | 66 // The client will now take control by calling provideInput() periodically. |
67 client_ = client; | 67 client_ = client; |
68 | 68 |
69 if (renderer_) { | 69 if (renderer_) { |
70 // The client needs to be notified of the audio format, if available. | 70 // The client needs to be notified of the audio format, if available. |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 channels_ = params.channels(); | 165 channels_ = params.channels(); |
166 sample_rate_ = params.sample_rate(); | 166 sample_rate_ = params.sample_rate(); |
167 | 167 |
168 if (client_) { | 168 if (client_) { |
169 // Inform WebKit about the audio stream format. | 169 // Inform WebKit about the audio stream format. |
170 client_->setFormat(channels_, sample_rate_); | 170 client_->setFormat(channels_, sample_rate_); |
171 } | 171 } |
172 } | 172 } |
173 | 173 |
174 } // namespace content | 174 } // namespace content |
OLD | NEW |