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

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

Issue 9121045: Switch AudioDevice classes from SyncSocket to CancelableSyncSocket. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments, add temporary ScopedAllowIO for the audio thread cleanup+TODO for next cl. Created 8 years, 10 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
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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 85
86 void AudioSyncReader::Close() { 86 void AudioSyncReader::Close() {
87 base::AutoLock auto_lock(lock_); 87 base::AutoLock auto_lock(lock_);
88 if (socket_.get()) { 88 if (socket_.get()) {
89 socket_->Close(); 89 socket_->Close();
90 socket_.reset(NULL); 90 socket_.reset(NULL);
91 } 91 }
92 } 92 }
93 93
94 bool AudioSyncReader::Init() { 94 bool AudioSyncReader::Init() {
95 socket_.reset(new base::SyncSocket()); 95 socket_.reset(new base::CancelableSyncSocket());
96 foreign_socket_.reset(new base::SyncSocket()); 96 foreign_socket_.reset(new base::CancelableSyncSocket());
97 return base::SyncSocket::CreatePair(socket_.get(), foreign_socket_.get()); 97 return base::CancelableSyncSocket::CreatePair(socket_.get(),
98 foreign_socket_.get());
98 } 99 }
99 100
100 #if defined(OS_WIN) 101 #if defined(OS_WIN)
101 bool AudioSyncReader::PrepareForeignSocketHandle( 102 bool AudioSyncReader::PrepareForeignSocketHandle(
102 base::ProcessHandle process_handle, 103 base::ProcessHandle process_handle,
103 base::SyncSocket::Handle* foreign_handle) { 104 base::SyncSocket::Handle* foreign_handle) {
104 ::DuplicateHandle(GetCurrentProcess(), foreign_socket_->handle(), 105 ::DuplicateHandle(GetCurrentProcess(), foreign_socket_->handle(),
105 process_handle, foreign_handle, 106 process_handle, foreign_handle,
106 0, FALSE, DUPLICATE_SAME_ACCESS); 107 0, FALSE, DUPLICATE_SAME_ACCESS);
107 if (*foreign_handle != 0) 108 if (*foreign_handle != 0)
108 return true; 109 return true;
109 return false; 110 return false;
110 } 111 }
111 #else 112 #else
112 bool AudioSyncReader::PrepareForeignSocketHandle( 113 bool AudioSyncReader::PrepareForeignSocketHandle(
113 base::ProcessHandle process_handle, 114 base::ProcessHandle process_handle,
114 base::FileDescriptor* foreign_handle) { 115 base::FileDescriptor* foreign_handle) {
115 foreign_handle->fd = foreign_socket_->handle(); 116 foreign_handle->fd = foreign_socket_->handle();
116 foreign_handle->auto_close = false; 117 foreign_handle->auto_close = false;
117 if (foreign_handle->fd != -1) 118 if (foreign_handle->fd != -1)
118 return true; 119 return true;
119 return false; 120 return false;
120 } 121 }
121 #endif 122 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698