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

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
Feng Qian 2014/05/20 15:53:12 #if defined(OS_ANDROID) #include "base/android/jni
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; 12 static const uint32 kLogDelayThreadholdMs = 500;
13 13
14 namespace content { 14 namespace content {
15 15
16 AudioInputSyncWriter::AudioInputSyncWriter( 16 AudioInputSyncWriter::AudioInputSyncWriter(
17 base::SharedMemory* shared_memory, 17 base::SharedMemory* shared_memory,
18 int shared_memory_segment_count) 18 int shared_memory_segment_count)
(...skipping 24 matching lines...) Expand all
43 base::TimeDelta interval = base::Time::Now() - creation_time_; 43 base::TimeDelta interval = base::Time::Now() - creation_time_;
44 oss << "Audio input data received for the first time: delay = " 44 oss << "Audio input data received for the first time: delay = "
45 << interval.InMilliseconds() << "ms."; 45 << interval.InMilliseconds() << "ms.";
46 } else { 46 } else {
47 base::TimeDelta interval = base::Time::Now() - last_write_time_; 47 base::TimeDelta interval = base::Time::Now() - last_write_time_;
48 if (interval.InMilliseconds() > kLogDelayThreadholdMs) { 48 if (interval.InMilliseconds() > kLogDelayThreadholdMs) {
49 oss << "Audio input data delay unexpectedly long: delay = " 49 oss << "Audio input data delay unexpectedly long: delay = "
50 << interval.InMilliseconds() << "ms."; 50 << interval.InMilliseconds() << "ms.";
51 } 51 }
52 } 52 }
53 if (!oss.str().empty()) 53 if (!oss.str().empty()) {
54 MediaStreamManager::SendMessageToNativeLog(oss.str()); 54 MediaStreamManager::SendMessageToNativeLog(oss.str());
Feng Qian 2014/05/19 23:27:01 I felt it is safer to disabling logging instead of
jiayl 2014/05/19 23:30:20 This is only called for the first audio sample dat
Feng Qian 2014/05/20 15:53:12 thanks for explanation, sounds fine to me. On 201
55 55
56 // MediaStreamManager::SendMessageToNativeLog posts a task to the UI thread,
Feng Qian 2014/05/20 15:53:12 Should comments be inside #if defined(OS_ANDROID)?
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 detach
60 // here to make sure the thread exits clean.
61 #if defined(OS_ANDROID)
62 base::android::DetachFromVM();
tommi (sloooow) - chröme 2014/05/20 12:28:29 Just so that I understand - from information in th
Feng Qian 2014/05/20 15:53:12 tommi@, not sure if I understand your question cor
jiayl 2014/05/20 15:56:14 The crash happens when the thread exists, not whil
63 #endif
64 }
65
56 last_write_time_ = base::Time::Now(); 66 last_write_time_ = base::Time::Now();
57 67
58 uint8* ptr = static_cast<uint8*>(shared_memory_->memory()); 68 uint8* ptr = static_cast<uint8*>(shared_memory_->memory());
59 ptr += current_segment_id_ * shared_memory_segment_size_; 69 ptr += current_segment_id_ * shared_memory_segment_size_;
60 media::AudioInputBuffer* buffer = 70 media::AudioInputBuffer* buffer =
61 reinterpret_cast<media::AudioInputBuffer*>(ptr); 71 reinterpret_cast<media::AudioInputBuffer*>(ptr);
62 buffer->params.volume = volume; 72 buffer->params.volume = volume;
63 buffer->params.size = size; 73 buffer->params.size = size;
64 buffer->params.key_pressed = key_pressed; 74 buffer->params.key_pressed = key_pressed;
65 memcpy(buffer->audio, data, size); 75 memcpy(buffer->audio, data, size);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 base::ProcessHandle process_handle, 108 base::ProcessHandle process_handle,
99 base::FileDescriptor* foreign_handle) { 109 base::FileDescriptor* foreign_handle) {
100 foreign_handle->fd = foreign_socket_->handle(); 110 foreign_handle->fd = foreign_socket_->handle();
101 foreign_handle->auto_close = false; 111 foreign_handle->auto_close = false;
102 return (foreign_handle->fd != -1); 112 return (foreign_handle->fd != -1);
103 } 113 }
104 114
105 #endif 115 #endif
106 116
107 } // namespace content 117 } // 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