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_sync_reader.h" | 5 #include "content/browser/renderer_host/media/audio_sync_reader.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/format_macros.h" | 10 #include "base/format_macros.h" |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 socket_->Close(); | 152 socket_->Close(); |
153 } | 153 } |
154 | 154 |
155 bool AudioSyncReader::Init() { | 155 bool AudioSyncReader::Init() { |
156 socket_.reset(new base::CancelableSyncSocket()); | 156 socket_.reset(new base::CancelableSyncSocket()); |
157 foreign_socket_.reset(new base::CancelableSyncSocket()); | 157 foreign_socket_.reset(new base::CancelableSyncSocket()); |
158 return base::CancelableSyncSocket::CreatePair(socket_.get(), | 158 return base::CancelableSyncSocket::CreatePair(socket_.get(), |
159 foreign_socket_.get()); | 159 foreign_socket_.get()); |
160 } | 160 } |
161 | 161 |
162 bool AudioSyncReader::PrepareForeignSocket( | 162 base::SyncSocket::Handle AudioSyncReader::GetSyncSocket() { |
163 base::ProcessHandle process_handle, | 163 base::SyncSocket::Handle handle = foreign_socket_.get()->handle(); |
164 base::SyncSocket::TransitDescriptor* descriptor) { | 164 foreign_socket_.reset(); |
165 return foreign_socket_->PrepareTransitDescriptor(process_handle, descriptor); | 165 return handle; |
166 } | 166 } |
167 | 167 |
168 bool AudioSyncReader::WaitUntilDataIsReady() { | 168 bool AudioSyncReader::WaitUntilDataIsReady() { |
169 TRACE_EVENT0("audio", "AudioSyncReader::WaitUntilDataIsReady"); | 169 TRACE_EVENT0("audio", "AudioSyncReader::WaitUntilDataIsReady"); |
170 base::TimeDelta timeout = maximum_wait_time_; | 170 base::TimeDelta timeout = maximum_wait_time_; |
171 const base::TimeTicks start_time = base::TimeTicks::Now(); | 171 const base::TimeTicks start_time = base::TimeTicks::Now(); |
172 const base::TimeTicks finish_time = start_time + timeout; | 172 const base::TimeTicks finish_time = start_time + timeout; |
173 | 173 |
174 // Check if data is ready and if not, wait a reasonable amount of time for it. | 174 // Check if data is ready and if not, wait a reasonable amount of time for it. |
175 // | 175 // |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 base::TimeDelta::FromMilliseconds(1), | 213 base::TimeDelta::FromMilliseconds(1), |
214 base::TimeDelta::FromMilliseconds(1000), | 214 base::TimeDelta::FromMilliseconds(1000), |
215 50); | 215 50); |
216 return false; | 216 return false; |
217 } | 217 } |
218 | 218 |
219 return true; | 219 return true; |
220 } | 220 } |
221 | 221 |
222 } // namespace content | 222 } // namespace content |
OLD | NEW |