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

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

Issue 495983002: Improve logging related to start/stop and failure of audio input streams in Chrome (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: nits 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 | Annotate | Revision Log
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_sync_writer.h" 5 #include "content/browser/renderer_host/media/audio_input_sync_writer.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/memory/shared_memory.h" 9 #include "base/memory/shared_memory.h"
10 #include "content/browser/renderer_host/media/media_stream_manager.h" 10 #include "content/browser/renderer_host/media/media_stream_manager.h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 socket_->Send(&bytes, sizeof(bytes)); 49 socket_->Send(&bytes, sizeof(bytes));
50 } 50 }
51 51
52 void AudioInputSyncWriter::Write(const media::AudioBus* data, 52 void AudioInputSyncWriter::Write(const media::AudioBus* data,
53 double volume, 53 double volume,
54 bool key_pressed) { 54 bool key_pressed) {
55 #if !defined(OS_ANDROID) 55 #if !defined(OS_ANDROID)
56 static const base::TimeDelta kLogDelayThreadhold = 56 static const base::TimeDelta kLogDelayThreadhold =
57 base::TimeDelta::FromMilliseconds(500); 57 base::TimeDelta::FromMilliseconds(500);
58 58
59 std::ostringstream oss; 59 std::ostringstream oss;
DaleCurtis 2014/08/26 20:09:29 Hmm, since this is called at a high frequency you
henrika (OOO until Aug 14) 2014/08/27 13:54:38 Sorry, not sure if I follow. I have not changed an
60 if (last_write_time_.is_null()) { 60 if (last_write_time_.is_null()) {
61 // This is the first time Write is called. 61 // This is the first time Write is called.
62 base::TimeDelta interval = base::Time::Now() - creation_time_; 62 base::TimeDelta interval = base::Time::Now() - creation_time_;
63 oss << "Audio input data received for the first time: delay = " 63 oss << "AISW::Write => audio input data received for the first time: delay "
64 << interval.InMilliseconds() << "ms."; 64 "= " << interval.InMilliseconds() << "ms";
65 65
66 } else { 66 } else {
67 base::TimeDelta interval = base::Time::Now() - last_write_time_; 67 base::TimeDelta interval = base::Time::Now() - last_write_time_;
68 if (interval > kLogDelayThreadhold) { 68 if (interval > kLogDelayThreadhold) {
69 oss << "Audio input data delay unexpectedly long: delay = " 69 oss << "AISW::Write => audio input data delay unexpectedly long: delay = "
70 << interval.InMilliseconds() << "ms."; 70 << interval.InMilliseconds() << "ms";
71 } 71 }
72 } 72 }
73 if (!oss.str().empty()) 73 if (!oss.str().empty()) {
74 MediaStreamManager::SendMessageToNativeLog(oss.str()); 74 MediaStreamManager::SendMessageToNativeLog(oss.str());
75 DVLOG(1) << oss.str();
76 }
75 77
76 last_write_time_ = base::Time::Now(); 78 last_write_time_ = base::Time::Now();
77 #endif 79 #endif
78 80
79 // Write audio parameters to shared memory. 81 // Write audio parameters to shared memory.
80 uint8* ptr = static_cast<uint8*>(shared_memory_->memory()); 82 uint8* ptr = static_cast<uint8*>(shared_memory_->memory());
81 ptr += current_segment_id_ * shared_memory_segment_size_; 83 ptr += current_segment_id_ * shared_memory_segment_size_;
82 media::AudioInputBuffer* buffer = 84 media::AudioInputBuffer* buffer =
83 reinterpret_cast<media::AudioInputBuffer*>(ptr); 85 reinterpret_cast<media::AudioInputBuffer*>(ptr);
84 buffer->params.volume = volume; 86 buffer->params.volume = volume;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 base::ProcessHandle process_handle, 124 base::ProcessHandle process_handle,
123 base::FileDescriptor* foreign_handle) { 125 base::FileDescriptor* foreign_handle) {
124 foreign_handle->fd = foreign_socket_->handle(); 126 foreign_handle->fd = foreign_socket_->handle();
125 foreign_handle->auto_close = false; 127 foreign_handle->auto_close = false;
126 return (foreign_handle->fd != -1); 128 return (foreign_handle->fd != -1);
127 } 129 }
128 130
129 #endif 131 #endif
130 132
131 } // namespace content 133 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698