OLD | NEW |
---|---|
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 #include "content/public/browser/browser_thread.h" | |
11 | 12 |
12 static const uint32 kLogDelayThreadholdMs = 500; | 13 static const uint32 kLogDelayThreadholdMs = 500; |
13 | 14 |
14 namespace content { | 15 namespace content { |
15 | 16 |
16 AudioInputSyncWriter::AudioInputSyncWriter( | 17 AudioInputSyncWriter::AudioInputSyncWriter( |
17 base::SharedMemory* shared_memory, | 18 base::SharedMemory* shared_memory, |
18 int shared_memory_segment_count) | 19 int shared_memory_segment_count) |
19 : shared_memory_(shared_memory), | 20 : shared_memory_(shared_memory), |
20 shared_memory_segment_count_(shared_memory_segment_count), | 21 shared_memory_segment_count_(shared_memory_segment_count), |
(...skipping 22 matching lines...) Expand all Loading... | |
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()) { |
55 #if defined(OS_ANDROID) | |
Ami GONE FROM CHROMIUM
2014/05/21 18:03:38
vrk@ points out that logging is not available on a
| |
56 // MediaStreamManager::SendMessageToNativeLog posts a task to the UI thread, | |
57 // which will attach the audio thread to the Android java VM. Unlike chrome | |
58 // created threads, the audio thread is owned by the OS and does not detach | |
59 // itself from the VM on exit, causing a crash (crbug/365915). So we post to | |
60 // the IO thread first to avoid attaching the audio thread to VM. | |
Ami GONE FROM CHROMIUM
2014/05/21 17:51:42
I don't get it.
How is it that the PostTask that
jiayl
2014/05/21 17:59:07
See https://code.google.com/p/chromium/issues/deta
Feng Qian
2014/05/21 18:08:33
jiayl, can you build and test the new patch locall
jiayl
2014/05/21 18:13:58
Code removed for Android now.
| |
61 BrowserThread::PostTask( | |
62 BrowserThread::IO, FROM_HERE, | |
63 base::Bind(&MediaStreamManager::SendMessageToNativeLog, oss.str())); | |
64 #else | |
54 MediaStreamManager::SendMessageToNativeLog(oss.str()); | 65 MediaStreamManager::SendMessageToNativeLog(oss.str()); |
66 #endif | |
67 } | |
55 | 68 |
56 last_write_time_ = base::Time::Now(); | 69 last_write_time_ = base::Time::Now(); |
57 | 70 |
58 uint8* ptr = static_cast<uint8*>(shared_memory_->memory()); | 71 uint8* ptr = static_cast<uint8*>(shared_memory_->memory()); |
59 ptr += current_segment_id_ * shared_memory_segment_size_; | 72 ptr += current_segment_id_ * shared_memory_segment_size_; |
60 media::AudioInputBuffer* buffer = | 73 media::AudioInputBuffer* buffer = |
61 reinterpret_cast<media::AudioInputBuffer*>(ptr); | 74 reinterpret_cast<media::AudioInputBuffer*>(ptr); |
62 buffer->params.volume = volume; | 75 buffer->params.volume = volume; |
63 buffer->params.size = size; | 76 buffer->params.size = size; |
64 buffer->params.key_pressed = key_pressed; | 77 buffer->params.key_pressed = key_pressed; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
98 base::ProcessHandle process_handle, | 111 base::ProcessHandle process_handle, |
99 base::FileDescriptor* foreign_handle) { | 112 base::FileDescriptor* foreign_handle) { |
100 foreign_handle->fd = foreign_socket_->handle(); | 113 foreign_handle->fd = foreign_socket_->handle(); |
101 foreign_handle->auto_close = false; | 114 foreign_handle->auto_close = false; |
102 return (foreign_handle->fd != -1); | 115 return (foreign_handle->fd != -1); |
103 } | 116 } |
104 | 117 |
105 #endif | 118 #endif |
106 | 119 |
107 } // namespace content | 120 } // namespace content |
OLD | NEW |