Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(158)

Side by Side Diff: content/browser/renderer_host/media/audio_sync_reader.cc

Issue 10083064: Revert 132842 - If we are using blocking write, when the renderer stop getting the data without not… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/browser/renderer_host/media/audio_sync_reader.h ('k') | ipc/sync_socket_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
(...skipping 18 matching lines...) Expand all
29 29
30 // media::AudioOutputController::SyncReader implementations. 30 // media::AudioOutputController::SyncReader implementations.
31 void AudioSyncReader::UpdatePendingBytes(uint32 bytes) { 31 void AudioSyncReader::UpdatePendingBytes(uint32 bytes) {
32 if (bytes != static_cast<uint32>(media::AudioOutputController::kPauseMark)) { 32 if (bytes != static_cast<uint32>(media::AudioOutputController::kPauseMark)) {
33 // Store unknown length of data into buffer, so we later 33 // Store unknown length of data into buffer, so we later
34 // can find out if data became available. 34 // can find out if data became available.
35 media::SetUnknownDataSize( 35 media::SetUnknownDataSize(
36 shared_memory_, 36 shared_memory_,
37 media::PacketSizeSizeInBytes(shared_memory_->created_size())); 37 media::PacketSizeSizeInBytes(shared_memory_->created_size()));
38 } 38 }
39 39 base::AutoLock auto_lock(lock_);
40 if (socket_.get()) { 40 if (socket_.get()) {
41 socket_->Send(&bytes, sizeof(bytes)); 41 socket_->Send(&bytes, sizeof(bytes));
42 } 42 }
43 } 43 }
44 44
45 uint32 AudioSyncReader::Read(void* data, uint32 size) { 45 uint32 AudioSyncReader::Read(void* data, uint32 size) {
46 uint32 max_size = media::PacketSizeSizeInBytes( 46 uint32 max_size = media::PacketSizeSizeInBytes(
47 shared_memory_->created_size()); 47 shared_memory_->created_size());
48 48
49 #if defined(OS_WIN) 49 #if defined(OS_WIN)
(...skipping 27 matching lines...) Expand all
77 memset(shared_memory_->memory(), 0, max_size); 77 memset(shared_memory_->memory(), 0, max_size);
78 78
79 // Store unknown length of data into buffer, in case renderer does not store 79 // Store unknown length of data into buffer, in case renderer does not store
80 // the length itself. It also helps in decision if we need to yield. 80 // the length itself. It also helps in decision if we need to yield.
81 media::SetUnknownDataSize(shared_memory_, max_size); 81 media::SetUnknownDataSize(shared_memory_, max_size);
82 82
83 return read_size; 83 return read_size;
84 } 84 }
85 85
86 void AudioSyncReader::Close() { 86 void AudioSyncReader::Close() {
87 base::AutoLock auto_lock(lock_);
87 if (socket_.get()) { 88 if (socket_.get()) {
88 socket_->Close(); 89 socket_->Close();
90 socket_.reset(NULL);
89 } 91 }
90 } 92 }
91 93
92 bool AudioSyncReader::Init() { 94 bool AudioSyncReader::Init() {
93 socket_.reset(new base::CancelableSyncSocket()); 95 socket_.reset(new base::CancelableSyncSocket());
94 foreign_socket_.reset(new base::CancelableSyncSocket()); 96 foreign_socket_.reset(new base::CancelableSyncSocket());
95 return base::CancelableSyncSocket::CreatePair(socket_.get(), 97 return base::CancelableSyncSocket::CreatePair(socket_.get(),
96 foreign_socket_.get()); 98 foreign_socket_.get());
97 } 99 }
98 100
(...skipping 12 matching lines...) Expand all
111 bool AudioSyncReader::PrepareForeignSocketHandle( 113 bool AudioSyncReader::PrepareForeignSocketHandle(
112 base::ProcessHandle process_handle, 114 base::ProcessHandle process_handle,
113 base::FileDescriptor* foreign_handle) { 115 base::FileDescriptor* foreign_handle) {
114 foreign_handle->fd = foreign_socket_->handle(); 116 foreign_handle->fd = foreign_socket_->handle();
115 foreign_handle->auto_close = false; 117 foreign_handle->auto_close = false;
116 if (foreign_handle->fd != -1) 118 if (foreign_handle->fd != -1)
117 return true; 119 return true;
118 return false; 120 return false;
119 } 121 }
120 #endif 122 #endif
OLDNEW
« no previous file with comments | « content/browser/renderer_host/media/audio_sync_reader.h ('k') | ipc/sync_socket_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698