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

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

Issue 8965053: Implement support for a cancelable SyncSocket. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: addressed micro-nit Created 8 years, 11 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 | « base/sync_socket_win.cc ('k') | content/browser/renderer_host/media/audio_sync_reader.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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_input_sync_writer.h" 5 #include "content/browser/renderer_host/media/audio_input_sync_writer.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 13 matching lines...) Expand all
24 // Copy audio input samples from recorded data to shared memory. 24 // Copy audio input samples from recorded data to shared memory.
25 memcpy(shared_memory_->memory(), data, write_size); 25 memcpy(shared_memory_->memory(), data, write_size);
26 return write_size; 26 return write_size;
27 } 27 }
28 28
29 void AudioInputSyncWriter::Close() { 29 void AudioInputSyncWriter::Close() {
30 socket_->Close(); 30 socket_->Close();
31 } 31 }
32 32
33 bool AudioInputSyncWriter::Init() { 33 bool AudioInputSyncWriter::Init() {
34 base::SyncSocket* sockets[2] = {0}; 34 socket_.reset(new base::SyncSocket());
35 if (base::SyncSocket::CreatePair(sockets)) { 35 foreign_socket_.reset(new base::SyncSocket());
36 socket_.reset(sockets[0]); 36 return base::SyncSocket::CreatePair(socket_.get(), foreign_socket_.get());
37 foreign_socket_.reset(sockets[1]);
38 return true;
39 }
40 return false;
41 } 37 }
42 38
43 #if defined(OS_WIN) 39 #if defined(OS_WIN)
44 40
45 bool AudioInputSyncWriter::PrepareForeignSocketHandle( 41 bool AudioInputSyncWriter::PrepareForeignSocketHandle(
46 base::ProcessHandle process_handle, 42 base::ProcessHandle process_handle,
47 base::SyncSocket::Handle* foreign_handle) { 43 base::SyncSocket::Handle* foreign_handle) {
48 ::DuplicateHandle(GetCurrentProcess(), foreign_socket_->handle(), 44 ::DuplicateHandle(GetCurrentProcess(), foreign_socket_->handle(),
49 process_handle, foreign_handle, 45 process_handle, foreign_handle,
50 0, FALSE, DUPLICATE_SAME_ACCESS); 46 0, FALSE, DUPLICATE_SAME_ACCESS);
51 return (*foreign_handle != 0); 47 return (*foreign_handle != 0);
52 } 48 }
53 49
54 #else 50 #else
55 51
56 bool AudioInputSyncWriter::PrepareForeignSocketHandle( 52 bool AudioInputSyncWriter::PrepareForeignSocketHandle(
57 base::ProcessHandle process_handle, 53 base::ProcessHandle process_handle,
58 base::FileDescriptor* foreign_handle) { 54 base::FileDescriptor* foreign_handle) {
59 foreign_handle->fd = foreign_socket_->handle(); 55 foreign_handle->fd = foreign_socket_->handle();
60 foreign_handle->auto_close = false; 56 foreign_handle->auto_close = false;
61 return (foreign_handle->fd != -1); 57 return (foreign_handle->fd != -1);
62 } 58 }
63 59
64 #endif 60 #endif
OLDNEW
« no previous file with comments | « base/sync_socket_win.cc ('k') | content/browser/renderer_host/media/audio_sync_reader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698