Chromium Code Reviews| 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/memory/shared_memory.h" | 10 #include "base/memory/shared_memory.h" |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 76 socket_->Close(); | 76 socket_->Close(); |
| 77 } | 77 } |
| 78 | 78 |
| 79 bool AudioSyncReader::Init() { | 79 bool AudioSyncReader::Init() { |
| 80 socket_.reset(new base::CancelableSyncSocket()); | 80 socket_.reset(new base::CancelableSyncSocket()); |
| 81 foreign_socket_.reset(new base::CancelableSyncSocket()); | 81 foreign_socket_.reset(new base::CancelableSyncSocket()); |
| 82 return base::CancelableSyncSocket::CreatePair(socket_.get(), | 82 return base::CancelableSyncSocket::CreatePair(socket_.get(), |
| 83 foreign_socket_.get()); | 83 foreign_socket_.get()); |
| 84 } | 84 } |
| 85 | 85 |
| 86 #if defined(OS_WIN) | 86 bool AudioSyncReader::PrepareForeignSocket( |
| 87 bool AudioSyncReader::PrepareForeignSocketHandle( | |
| 88 base::ProcessHandle process_handle, | 87 base::ProcessHandle process_handle, |
| 89 base::SyncSocket::Handle* foreign_handle) { | 88 base::SyncSocket::TransitDescriptor * descriptor) { |
| 90 ::DuplicateHandle(GetCurrentProcess(), foreign_socket_->handle(), | 89 return foreign_socket_->PrepareTransitDescriptor( |
| 91 process_handle, foreign_handle, | 90 process_handle, descriptor); |
|
burnik
2014/09/01 14:59:34
Pulled to one line.
| |
| 92 0, FALSE, DUPLICATE_SAME_ACCESS); | |
| 93 return (*foreign_handle != 0); | |
| 94 } | 91 } |
| 95 #else | |
| 96 bool AudioSyncReader::PrepareForeignSocketHandle( | |
| 97 base::ProcessHandle process_handle, | |
| 98 base::FileDescriptor* foreign_handle) { | |
| 99 foreign_handle->fd = foreign_socket_->handle(); | |
| 100 foreign_handle->auto_close = false; | |
| 101 return (foreign_handle->fd != -1); | |
| 102 } | |
| 103 #endif | |
| 104 | 92 |
| 105 bool AudioSyncReader::WaitUntilDataIsReady() { | 93 bool AudioSyncReader::WaitUntilDataIsReady() { |
| 106 base::TimeDelta timeout = maximum_wait_time_; | 94 base::TimeDelta timeout = maximum_wait_time_; |
| 107 const base::TimeTicks start_time = base::TimeTicks::Now(); | 95 const base::TimeTicks start_time = base::TimeTicks::Now(); |
| 108 const base::TimeTicks finish_time = start_time + timeout; | 96 const base::TimeTicks finish_time = start_time + timeout; |
| 109 | 97 |
| 110 // Check if data is ready and if not, wait a reasonable amount of time for it. | 98 // Check if data is ready and if not, wait a reasonable amount of time for it. |
| 111 // | 99 // |
| 112 // Data readiness is achieved via parallel counters, one on the renderer side | 100 // Data readiness is achieved via parallel counters, one on the renderer side |
| 113 // and one here. Every time a buffer is requested via UpdatePendingBytes(), | 101 // and one here. Every time a buffer is requested via UpdatePendingBytes(), |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 147 base::TimeDelta::FromMilliseconds(1), | 135 base::TimeDelta::FromMilliseconds(1), |
| 148 base::TimeDelta::FromMilliseconds(1000), | 136 base::TimeDelta::FromMilliseconds(1000), |
| 149 50); | 137 50); |
| 150 return false; | 138 return false; |
| 151 } | 139 } |
| 152 | 140 |
| 153 return true; | 141 return true; |
| 154 } | 142 } |
| 155 | 143 |
| 156 } // namespace content | 144 } // namespace content |
| OLD | NEW |