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

Side by Side Diff: content/browser/renderer_host/media/audio_input_renderer_host.cc

Issue 524393002: Followup on "Improved logging for input streams" (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: removed git gl format changes Created 6 years, 3 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 | « no previous file | content/browser/renderer_host/media/audio_input_sync_writer.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 (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/browser/renderer_host/media/audio_input_renderer_host.h" 5 #include "content/browser/renderer_host/media/audio_input_renderer_host.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/memory/shared_memory.h" 8 #include "base/memory/shared_memory.h"
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/numerics/safe_math.h" 10 #include "base/numerics/safe_math.h"
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 186
187 // If we failed to prepare the sync socket for the renderer then we fail 187 // If we failed to prepare the sync socket for the renderer then we fail
188 // the construction of audio input stream. 188 // the construction of audio input stream.
189 if (!writer->PrepareForeignSocketHandle(PeerHandle(), 189 if (!writer->PrepareForeignSocketHandle(PeerHandle(),
190 &foreign_socket_handle)) { 190 &foreign_socket_handle)) {
191 DeleteEntryOnError(entry, SYNC_SOCKET_ERROR); 191 DeleteEntryOnError(entry, SYNC_SOCKET_ERROR);
192 return; 192 return;
193 } 193 }
194 194
195 LogMessage(entry->stream_id, 195 LogMessage(entry->stream_id,
196 "DoCompleteCreation => IPC channel and stream are now open", 196 "DoCompleteCreation: IPC channel and stream are now open",
197 true); 197 true);
198 198
199 Send(new AudioInputMsg_NotifyStreamCreated(entry->stream_id, 199 Send(new AudioInputMsg_NotifyStreamCreated(entry->stream_id,
200 foreign_memory_handle, foreign_socket_handle, 200 foreign_memory_handle, foreign_socket_handle,
201 entry->shared_memory.requested_size(), 201 entry->shared_memory.requested_size(),
202 entry->shared_memory_segment_count)); 202 entry->shared_memory_segment_count));
203 } 203 }
204 204
205 void AudioInputRendererHost::DoSendRecordingMessage( 205 void AudioInputRendererHost::DoSendRecordingMessage(
206 media::AudioInputController* controller) { 206 media::AudioInputController* controller) {
207 DCHECK_CURRENTLY_ON(BrowserThread::IO); 207 DCHECK_CURRENTLY_ON(BrowserThread::IO);
208 // TODO(henrika): See crbug.com/115262 for details on why this method 208 // TODO(henrika): See crbug.com/115262 for details on why this method
209 // should be implemented. 209 // should be implemented.
210 AudioEntry* entry = LookupByController(controller); 210 AudioEntry* entry = LookupByController(controller);
211 if (!entry) { 211 if (!entry) {
212 NOTREACHED() << "AudioInputController is invalid."; 212 NOTREACHED() << "AudioInputController is invalid.";
213 return; 213 return;
214 } 214 }
215 LogMessage(entry->stream_id, 215 LogMessage(
216 "DoSendRecordingMessage => stream is now started", 216 entry->stream_id, "DoSendRecordingMessage: stream is now started", true);
217 true);
218 } 217 }
219 218
220 void AudioInputRendererHost::DoHandleError( 219 void AudioInputRendererHost::DoHandleError(
221 media::AudioInputController* controller, 220 media::AudioInputController* controller,
222 media::AudioInputController::ErrorCode error_code) { 221 media::AudioInputController::ErrorCode error_code) {
223 DCHECK_CURRENTLY_ON(BrowserThread::IO); 222 DCHECK_CURRENTLY_ON(BrowserThread::IO);
224 AudioEntry* entry = LookupByController(controller); 223 AudioEntry* entry = LookupByController(controller);
225 if (!entry) { 224 if (!entry) {
226 NOTREACHED() << "AudioInputController is invalid."; 225 NOTREACHED() << "AudioInputController is invalid.";
227 return; 226 return;
228 } 227 }
229 228
230 // This is a fix for crbug.com/357501. The error can be triggered when closing 229 // This is a fix for crbug.com/357501. The error can be triggered when closing
231 // the lid on Macs, which causes more problems than it fixes. 230 // the lid on Macs, which causes more problems than it fixes.
232 // Also, in crbug.com/357569, the goal is to remove usage of the error since 231 // Also, in crbug.com/357569, the goal is to remove usage of the error since
233 // it was added to solve a crash on Windows that no longer can be reproduced. 232 // it was added to solve a crash on Windows that no longer can be reproduced.
234 if (error_code == media::AudioInputController::NO_DATA_ERROR) { 233 if (error_code == media::AudioInputController::NO_DATA_ERROR) {
235 // TODO(henrika): it might be possible to do something other than just 234 // TODO(henrika): it might be possible to do something other than just
236 // logging when we detect many NO_DATA_ERROR calls for a stream. 235 // logging when we detect many NO_DATA_ERROR calls for a stream.
237 LogMessage(entry->stream_id, "AIC => NO_DATA_ERROR", false); 236 LogMessage(entry->stream_id, "AIC::DoCheckForNoData: NO_DATA_ERROR", false);
238 return; 237 return;
239 } 238 }
240 239
241 std::ostringstream oss; 240 std::ostringstream oss;
242 oss << "AIC reports error_code=" << error_code; 241 oss << "AIC reports error_code=" << error_code;
243 LogMessage(entry->stream_id, oss.str(), false); 242 LogMessage(entry->stream_id, oss.str(), false);
244 243
245 audio_log_->OnError(entry->stream_id); 244 audio_log_->OnError(entry->stream_id);
246 DeleteEntryOnError(entry, AUDIO_INPUT_CONTROLLER_ERROR); 245 DeleteEntryOnError(entry, AUDIO_INPUT_CONTROLLER_ERROR);
247 } 246 }
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 LogMessage(entry->stream_id, "CloseAndDeleteStream", true); 457 LogMessage(entry->stream_id, "CloseAndDeleteStream", true);
459 entry->controller->Close(base::Bind(&AudioInputRendererHost::DeleteEntry, 458 entry->controller->Close(base::Bind(&AudioInputRendererHost::DeleteEntry,
460 this, entry)); 459 this, entry));
461 entry->pending_close = true; 460 entry->pending_close = true;
462 audio_log_->OnClosed(entry->stream_id); 461 audio_log_->OnClosed(entry->stream_id);
463 } 462 }
464 } 463 }
465 464
466 void AudioInputRendererHost::DeleteEntry(AudioEntry* entry) { 465 void AudioInputRendererHost::DeleteEntry(AudioEntry* entry) {
467 DCHECK_CURRENTLY_ON(BrowserThread::IO); 466 DCHECK_CURRENTLY_ON(BrowserThread::IO);
468 LogMessage(entry->stream_id, "DeleteEntry => stream is now closed", true); 467 LogMessage(entry->stream_id, "DeleteEntry: stream is now closed", true);
469 468
470 // Delete the entry when this method goes out of scope. 469 // Delete the entry when this method goes out of scope.
471 scoped_ptr<AudioEntry> entry_deleter(entry); 470 scoped_ptr<AudioEntry> entry_deleter(entry);
472 471
473 // Erase the entry from the map. 472 // Erase the entry from the map.
474 audio_entries_.erase(entry->stream_id); 473 audio_entries_.erase(entry->stream_id);
475 } 474 }
476 475
477 void AudioInputRendererHost::DeleteEntryOnError(AudioEntry* entry, 476 void AudioInputRendererHost::DeleteEntryOnError(AudioEntry* entry,
478 ErrorCode error_code) { 477 ErrorCode error_code) {
(...skipping 23 matching lines...) Expand all
502 // TODO(hclam): Implement a faster look up method. 501 // TODO(hclam): Implement a faster look up method.
503 for (AudioEntryMap::iterator i = audio_entries_.begin(); 502 for (AudioEntryMap::iterator i = audio_entries_.begin();
504 i != audio_entries_.end(); ++i) { 503 i != audio_entries_.end(); ++i) {
505 if (controller == i->second->controller.get()) 504 if (controller == i->second->controller.get())
506 return i->second; 505 return i->second;
507 } 506 }
508 return NULL; 507 return NULL;
509 } 508 }
510 509
511 } // namespace content 510 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/renderer_host/media/audio_input_sync_writer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698