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/process_util.h" | 9 #include "base/process_util.h" |
10 #include "base/shared_memory.h" | 10 #include "base/shared_memory.h" |
11 #include "base/threading/platform_thread.h" | 11 #include "base/threading/platform_thread.h" |
12 #include "media/audio/audio_buffers_state.h" | 12 #include "media/audio/audio_buffers_state.h" |
13 #include "media/audio/audio_util.h" | 13 #include "media/audio/shared_memory_util.h" |
14 | 14 |
15 #if defined(OS_WIN) | 15 #if defined(OS_WIN) |
16 const int kMinIntervalBetweenReadCallsInMs = 10; | 16 const int kMinIntervalBetweenReadCallsInMs = 10; |
17 #endif | 17 #endif |
18 | 18 |
19 AudioSyncReader::AudioSyncReader(base::SharedMemory* shared_memory) | 19 AudioSyncReader::AudioSyncReader(base::SharedMemory* shared_memory) |
20 : shared_memory_(shared_memory) { | 20 : shared_memory_(shared_memory) { |
21 } | 21 } |
22 | 22 |
23 AudioSyncReader::~AudioSyncReader() { | 23 AudioSyncReader::~AudioSyncReader() { |
24 } | 24 } |
25 | 25 |
26 bool AudioSyncReader::DataReady() { | 26 bool AudioSyncReader::DataReady() { |
27 return !media::IsUnknownDataSize( | 27 return !media::IsUnknownDataSize( |
28 shared_memory_, | 28 shared_memory_, |
29 media::PacketSizeSizeInBytes(shared_memory_->created_size())); | 29 media::PacketSizeSizeInBytes(shared_memory_->created_size())); |
30 } | 30 } |
31 | 31 |
32 // media::AudioOutputController::SyncReader implementations. | 32 // media::AudioOutputController::SyncReader implementations. |
33 void AudioSyncReader::UpdatePendingBytes(uint32 bytes) { | 33 void AudioSyncReader::UpdatePendingBytes(uint32 bytes) { |
34 if (bytes != static_cast<uint32>(media::AudioOutputController::kPauseMark)) { | 34 if (bytes != static_cast<uint32>(media::kPauseMark)) { |
35 // Store unknown length of data into buffer, so we later | 35 // Store unknown length of data into buffer, so we later |
36 // can find out if data became available. | 36 // can find out if data became available. |
37 media::SetUnknownDataSize( | 37 media::SetUnknownDataSize( |
38 shared_memory_, | 38 shared_memory_, |
39 media::PacketSizeSizeInBytes(shared_memory_->created_size())); | 39 media::PacketSizeSizeInBytes(shared_memory_->created_size())); |
40 } | 40 } |
41 | 41 |
42 if (socket_.get()) { | 42 if (socket_.get()) { |
43 socket_->Send(&bytes, sizeof(bytes)); | 43 socket_->Send(&bytes, sizeof(bytes)); |
44 } | 44 } |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 bool AudioSyncReader::PrepareForeignSocketHandle( | 113 bool AudioSyncReader::PrepareForeignSocketHandle( |
114 base::ProcessHandle process_handle, | 114 base::ProcessHandle process_handle, |
115 base::FileDescriptor* foreign_handle) { | 115 base::FileDescriptor* foreign_handle) { |
116 foreign_handle->fd = foreign_socket_->handle(); | 116 foreign_handle->fd = foreign_socket_->handle(); |
117 foreign_handle->auto_close = false; | 117 foreign_handle->auto_close = false; |
118 if (foreign_handle->fd != -1) | 118 if (foreign_handle->fd != -1) |
119 return true; | 119 return true; |
120 return false; | 120 return false; |
121 } | 121 } |
122 #endif | 122 #endif |
OLD | NEW |