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

Side by Side Diff: media/blink/webaudiosourceprovider_impl.cc

Issue 1083883003: Move BindToCurrentLoop from media/base/ to base/ Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix media/base/callback_holder.h compile Created 5 years, 8 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
« no previous file with comments | « media/blink/texttrack_impl.cc ('k') | media/blink/webmediaplayer_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "media/blink/webaudiosourceprovider_impl.h" 5 #include "media/blink/webaudiosourceprovider_impl.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_to_current_loop.h"
10 #include "base/callback_helpers.h" 11 #include "base/callback_helpers.h"
11 #include "base/logging.h" 12 #include "base/logging.h"
12 #include "media/base/bind_to_current_loop.h"
13 #include "third_party/WebKit/public/platform/WebAudioSourceProviderClient.h" 13 #include "third_party/WebKit/public/platform/WebAudioSourceProviderClient.h"
14 14
15 using blink::WebVector; 15 using blink::WebVector;
16 16
17 namespace media { 17 namespace media {
18 18
19 namespace { 19 namespace {
20 20
21 // Simple helper class for Try() locks. Lock is Try()'d on construction and 21 // Simple helper class for Try() locks. Lock is Try()'d on construction and
22 // must be checked via the locked() attribute. If acquisition was successful 22 // must be checked via the locked() attribute. If acquisition was successful
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 void WebAudioSourceProviderImpl::setClient( 63 void WebAudioSourceProviderImpl::setClient(
64 blink::WebAudioSourceProviderClient* client) { 64 blink::WebAudioSourceProviderClient* client) {
65 base::AutoLock auto_lock(sink_lock_); 65 base::AutoLock auto_lock(sink_lock_);
66 if (client && client != client_) { 66 if (client && client != client_) {
67 // Detach the audio renderer from normal playback. 67 // Detach the audio renderer from normal playback.
68 sink_->Stop(); 68 sink_->Stop();
69 69
70 // The client will now take control by calling provideInput() periodically. 70 // The client will now take control by calling provideInput() periodically.
71 client_ = client; 71 client_ = client;
72 72
73 set_format_cb_ = BindToCurrentLoop(base::Bind( 73 set_format_cb_ = base::BindToCurrentLoop(base::Bind(
74 &WebAudioSourceProviderImpl::OnSetFormat, weak_factory_.GetWeakPtr())); 74 &WebAudioSourceProviderImpl::OnSetFormat, weak_factory_.GetWeakPtr()));
75 75
76 // If |renderer_| is set, then run |set_format_cb_| to send |client_| 76 // If |renderer_| is set, then run |set_format_cb_| to send |client_|
77 // the current format info. If |renderer_| is not set, then |set_format_cb_| 77 // the current format info. If |renderer_| is not set, then |set_format_cb_|
78 // will get called when Initialize() is called. 78 // will get called when Initialize() is called.
79 // Note: Always using |set_format_cb_| ensures we have the same 79 // Note: Always using |set_format_cb_| ensures we have the same
80 // locking order when calling into |client_|. 80 // locking order when calling into |client_|.
81 if (renderer_) 81 if (renderer_)
82 base::ResetAndReturn(&set_format_cb_).Run(); 82 base::ResetAndReturn(&set_format_cb_).Run();
83 } else if (!client && client_) { 83 } else if (!client && client_) {
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 void WebAudioSourceProviderImpl::OnSetFormat() { 184 void WebAudioSourceProviderImpl::OnSetFormat() {
185 base::AutoLock auto_lock(sink_lock_); 185 base::AutoLock auto_lock(sink_lock_);
186 if (!client_) 186 if (!client_)
187 return; 187 return;
188 188
189 // Inform Blink about the audio stream format. 189 // Inform Blink about the audio stream format.
190 client_->setFormat(channels_, sample_rate_); 190 client_->setFormat(channels_, sample_rate_);
191 } 191 }
192 192
193 } // namespace media 193 } // namespace media
OLDNEW
« no previous file with comments | « media/blink/texttrack_impl.cc ('k') | media/blink/webmediaplayer_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698