| 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 #include <limits> |
| 8 #include <string> | 9 #include <string> |
| 9 #include <utility> | 10 #include <utility> |
| 10 | 11 |
| 11 #include "base/command_line.h" | 12 #include "base/command_line.h" |
| 12 #include "base/format_macros.h" | 13 #include "base/format_macros.h" |
| 13 #include "base/memory/ptr_util.h" | 14 #include "base/memory/ptr_util.h" |
| 14 #include "base/memory/shared_memory.h" | 15 #include "base/memory/shared_memory.h" |
| 15 #include "base/metrics/histogram_macros.h" | 16 #include "base/metrics/histogram_macros.h" |
| 16 #include "base/strings/stringprintf.h" | 17 #include "base/strings/stringprintf.h" |
| 17 #include "base/trace_event/trace_event.h" | 18 #include "base/trace_event/trace_event.h" |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 !shared_memory->CreateAndMapAnonymous(memory_size.ValueOrDie()) || | 134 !shared_memory->CreateAndMapAnonymous(memory_size.ValueOrDie()) || |
| 134 !base::CancelableSyncSocket::CreatePair(socket.get(), | 135 !base::CancelableSyncSocket::CreatePair(socket.get(), |
| 135 foreign_socket.get())) { | 136 foreign_socket.get())) { |
| 136 return nullptr; | 137 return nullptr; |
| 137 } | 138 } |
| 138 return base::WrapUnique(new AudioSyncReader(params, std::move(shared_memory), | 139 return base::WrapUnique(new AudioSyncReader(params, std::move(shared_memory), |
| 139 std::move(socket), | 140 std::move(socket), |
| 140 std::move(foreign_socket))); | 141 std::move(foreign_socket))); |
| 141 } | 142 } |
| 142 | 143 |
| 144 std::unique_ptr<base::CancelableSyncSocket> |
| 145 AudioSyncReader::TakeForeignSocket() { |
| 146 DCHECK(foreign_socket_); |
| 147 return std::move(foreign_socket_); |
| 148 } |
| 149 |
| 143 // media::AudioOutputController::SyncReader implementations. | 150 // media::AudioOutputController::SyncReader implementations. |
| 144 void AudioSyncReader::RequestMoreData(base::TimeDelta delay, | 151 void AudioSyncReader::RequestMoreData(base::TimeDelta delay, |
| 145 base::TimeTicks delay_timestamp, | 152 base::TimeTicks delay_timestamp, |
| 146 int prior_frames_skipped) { | 153 int prior_frames_skipped) { |
| 147 // We don't send arguments over the socket since sending more than 4 | 154 // We don't send arguments over the socket since sending more than 4 |
| 148 // bytes might lead to being descheduled. The reading side will zero | 155 // bytes might lead to being descheduled. The reading side will zero |
| 149 // them when consumed. | 156 // them when consumed. |
| 150 AudioOutputBuffer* buffer = | 157 AudioOutputBuffer* buffer = |
| 151 reinterpret_cast<AudioOutputBuffer*>(shared_memory_->memory()); | 158 reinterpret_cast<AudioOutputBuffer*>(shared_memory_->memory()); |
| 152 // Increase the number of skipped frames stored in shared memory. | 159 // Increase the number of skipped frames stored in shared memory. |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 base::TimeDelta::FromMilliseconds(1), | 261 base::TimeDelta::FromMilliseconds(1), |
| 255 base::TimeDelta::FromMilliseconds(1000), | 262 base::TimeDelta::FromMilliseconds(1000), |
| 256 50); | 263 50); |
| 257 return false; | 264 return false; |
| 258 } | 265 } |
| 259 | 266 |
| 260 return true; | 267 return true; |
| 261 } | 268 } |
| 262 | 269 |
| 263 } // namespace content | 270 } // namespace content |
| OLD | NEW |