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

Side by Side Diff: content/renderer/media/render_audiosourceprovider.cc

Issue 10084022: Fix crash when changing sources after createMediaSourceElement(). (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Created 8 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/render_audiosourceprovider.h" 5 #include "content/renderer/media/render_audiosourceprovider.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "third_party/WebKit/Source/WebKit/chromium/public/WebAudioSourceProvide rClient.h" 9 #include "third_party/WebKit/Source/WebKit/chromium/public/WebAudioSourceProvide rClient.h"
10 10
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 is_initialized_ = true; 98 is_initialized_ = true;
99 } 99 }
100 100
101 void RenderAudioSourceProvider::setClient( 101 void RenderAudioSourceProvider::setClient(
102 WebKit::WebAudioSourceProviderClient* client) { 102 WebKit::WebAudioSourceProviderClient* client) {
103 // Synchronize with other uses of client_ and default_sink_. 103 // Synchronize with other uses of client_ and default_sink_.
104 base::AutoLock auto_lock(sink_lock_); 104 base::AutoLock auto_lock(sink_lock_);
105 105
106 if (client && client != client_) { 106 if (client && client != client_) {
107 // Detach the audio renderer from normal playback. 107 // Detach the audio renderer from normal playback.
108 default_sink_->Pause(true); 108 default_sink_->Stop();
109 109
110 // The client will now take control by calling provideInput() periodically. 110 // The client will now take control by calling provideInput() periodically.
111 client_ = client; 111 client_ = client;
112 112
113 if (is_initialized_) { 113 if (is_initialized_) {
114 // The client needs to be notified of the audio format, if available. 114 // The client needs to be notified of the audio format, if available.
115 // If the format is not yet available, we'll be notified later 115 // If the format is not yet available, we'll be notified later
116 // when Initialize() is called. 116 // when Initialize() is called.
117 117
118 // Inform WebKit about the audio stream format. 118 // Inform WebKit about the audio stream format.
(...skipping 19 matching lines...) Expand all
138 138
139 // TODO(crogers): figure out if we should volume scale here or in common 139 // TODO(crogers): figure out if we should volume scale here or in common
140 // WebAudio code. In any case we need to take care of volume. 140 // WebAudio code. In any case we need to take care of volume.
141 renderer_->Render(v, number_of_frames, 0); 141 renderer_->Render(v, number_of_frames, 0);
142 } else { 142 } else {
143 // Provide silence if the source is not running. 143 // Provide silence if the source is not running.
144 for (size_t i = 0; i < audio_data.size(); ++i) 144 for (size_t i = 0; i < audio_data.size(); ++i)
145 memset(audio_data[i], 0, sizeof(float) * number_of_frames); 145 memset(audio_data[i], 0, sizeof(float) * number_of_frames);
146 } 146 }
147 } 147 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698