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

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

Issue 294803003: Do not call SendMessageToNativeLog on Android in AudioInputSyncWriter (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@temp
Patch Set: Created 6 years, 7 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 | 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/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"
11 11
12 static const uint32 kLogDelayThreadholdMs = 500;
13
14 namespace content { 12 namespace content {
15 13
16 AudioInputSyncWriter::AudioInputSyncWriter( 14 AudioInputSyncWriter::AudioInputSyncWriter(
17 base::SharedMemory* shared_memory, 15 base::SharedMemory* shared_memory,
18 int shared_memory_segment_count) 16 int shared_memory_segment_count)
19 : shared_memory_(shared_memory), 17 : shared_memory_(shared_memory),
20 shared_memory_segment_count_(shared_memory_segment_count), 18 shared_memory_segment_count_(shared_memory_segment_count),
21 current_segment_id_(0), 19 current_segment_id_(0),
22 creation_time_(base::Time::Now()) { 20 creation_time_(base::Time::Now()) {
23 DCHECK_GT(shared_memory_segment_count, 0); 21 DCHECK_GT(shared_memory_segment_count, 0);
24 DCHECK_EQ(shared_memory->requested_size() % shared_memory_segment_count, 0u); 22 DCHECK_EQ(shared_memory->requested_size() % shared_memory_segment_count, 0u);
25 shared_memory_segment_size_ = 23 shared_memory_segment_size_ =
26 shared_memory->requested_size() / shared_memory_segment_count; 24 shared_memory->requested_size() / shared_memory_segment_count;
27 } 25 }
28 26
29 AudioInputSyncWriter::~AudioInputSyncWriter() {} 27 AudioInputSyncWriter::~AudioInputSyncWriter() {}
30 28
31 // TODO(henrika): Combine into one method (including Write). 29 // TODO(henrika): Combine into one method (including Write).
32 void AudioInputSyncWriter::UpdateRecordedBytes(uint32 bytes) { 30 void AudioInputSyncWriter::UpdateRecordedBytes(uint32 bytes) {
33 socket_->Send(&bytes, sizeof(bytes)); 31 socket_->Send(&bytes, sizeof(bytes));
34 } 32 }
35 33
36 uint32 AudioInputSyncWriter::Write(const void* data, 34 uint32 AudioInputSyncWriter::Write(const void* data,
37 uint32 size, 35 uint32 size,
38 double volume, 36 double volume,
39 bool key_pressed) { 37 bool key_pressed) {
38 #if !defined(OS_ANDROID)
39 static const uint32 kLogDelayThreadholdMs = 500;
Ami GONE FROM CHROMIUM 2014/05/21 18:38:38 FWIW now that this is a function-static instead of
40
40 std::ostringstream oss; 41 std::ostringstream oss;
41 if (last_write_time_.is_null()) { 42 if (last_write_time_.is_null()) {
42 // This is the first time Write is called. 43 // This is the first time Write is called.
43 base::TimeDelta interval = base::Time::Now() - creation_time_; 44 base::TimeDelta interval = base::Time::Now() - creation_time_;
44 oss << "Audio input data received for the first time: delay = " 45 oss << "Audio input data received for the first time: delay = "
45 << interval.InMilliseconds() << "ms."; 46 << interval.InMilliseconds() << "ms.";
46 } else { 47 } else {
47 base::TimeDelta interval = base::Time::Now() - last_write_time_; 48 base::TimeDelta interval = base::Time::Now() - last_write_time_;
48 if (interval.InMilliseconds() > kLogDelayThreadholdMs) { 49 if (interval.InMilliseconds() > kLogDelayThreadholdMs) {
49 oss << "Audio input data delay unexpectedly long: delay = " 50 oss << "Audio input data delay unexpectedly long: delay = "
50 << interval.InMilliseconds() << "ms."; 51 << interval.InMilliseconds() << "ms.";
51 } 52 }
52 } 53 }
53 if (!oss.str().empty()) 54 if (!oss.str().empty())
54 MediaStreamManager::SendMessageToNativeLog(oss.str()); 55 MediaStreamManager::SendMessageToNativeLog(oss.str());
55 56
56 last_write_time_ = base::Time::Now(); 57 last_write_time_ = base::Time::Now();
58 #endif
57 59
58 uint8* ptr = static_cast<uint8*>(shared_memory_->memory()); 60 uint8* ptr = static_cast<uint8*>(shared_memory_->memory());
59 ptr += current_segment_id_ * shared_memory_segment_size_; 61 ptr += current_segment_id_ * shared_memory_segment_size_;
60 media::AudioInputBuffer* buffer = 62 media::AudioInputBuffer* buffer =
61 reinterpret_cast<media::AudioInputBuffer*>(ptr); 63 reinterpret_cast<media::AudioInputBuffer*>(ptr);
62 buffer->params.volume = volume; 64 buffer->params.volume = volume;
63 buffer->params.size = size; 65 buffer->params.size = size;
64 buffer->params.key_pressed = key_pressed; 66 buffer->params.key_pressed = key_pressed;
65 memcpy(buffer->audio, data, size); 67 memcpy(buffer->audio, data, size);
66 68
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 base::ProcessHandle process_handle, 100 base::ProcessHandle process_handle,
99 base::FileDescriptor* foreign_handle) { 101 base::FileDescriptor* foreign_handle) {
100 foreign_handle->fd = foreign_socket_->handle(); 102 foreign_handle->fd = foreign_socket_->handle();
101 foreign_handle->auto_close = false; 103 foreign_handle->auto_close = false;
102 return (foreign_handle->fd != -1); 104 return (foreign_handle->fd != -1);
103 } 105 }
104 106
105 #endif 107 #endif
106 108
107 } // namespace content 109 } // namespace content
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