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 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 output_bus_->CopyTo(dest); | 148 output_bus_->CopyTo(dest); |
149 } | 149 } |
150 | 150 |
151 void AudioSyncReader::Close() { | 151 void AudioSyncReader::Close() { |
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 bool b = base::CancelableSyncSocket::CreatePair(socket_.get(), |
159 foreign_socket_.get()); | 159 foreign_socket_.get()); |
| 160 return b; |
160 } | 161 } |
161 | 162 |
162 bool AudioSyncReader::PrepareForeignSocket( | 163 base::SyncSocket::Handle AudioSyncReader::GetSyncSocket() { |
163 base::ProcessHandle process_handle, | 164 base::SyncSocket::Handle handle = foreign_socket_.get()->handle(); |
164 base::SyncSocket::TransitDescriptor* descriptor) { | 165 // Since the syncsocket will close the handle, we have to dup it. |
165 return foreign_socket_->PrepareTransitDescriptor(process_handle, descriptor); | 166 // TODO multiplatform. |
| 167 return dup(handle); |
166 } | 168 } |
167 | 169 |
168 bool AudioSyncReader::WaitUntilDataIsReady() { | 170 bool AudioSyncReader::WaitUntilDataIsReady() { |
169 TRACE_EVENT0("audio", "AudioSyncReader::WaitUntilDataIsReady"); | 171 TRACE_EVENT0("audio", "AudioSyncReader::WaitUntilDataIsReady"); |
170 base::TimeDelta timeout = maximum_wait_time_; | 172 base::TimeDelta timeout = maximum_wait_time_; |
171 const base::TimeTicks start_time = base::TimeTicks::Now(); | 173 const base::TimeTicks start_time = base::TimeTicks::Now(); |
172 const base::TimeTicks finish_time = start_time + timeout; | 174 const base::TimeTicks finish_time = start_time + timeout; |
173 | 175 |
174 // Check if data is ready and if not, wait a reasonable amount of time for it. | 176 // Check if data is ready and if not, wait a reasonable amount of time for it. |
175 // | 177 // |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 base::TimeDelta::FromMilliseconds(1), | 215 base::TimeDelta::FromMilliseconds(1), |
214 base::TimeDelta::FromMilliseconds(1000), | 216 base::TimeDelta::FromMilliseconds(1000), |
215 50); | 217 50); |
216 return false; | 218 return false; |
217 } | 219 } |
218 | 220 |
219 return true; | 221 return true; |
220 } | 222 } |
221 | 223 |
222 } // namespace content | 224 } // namespace content |
OLD | NEW |