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

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

Issue 14081010: Cleanup: Remove unnecessary ".get()" from scoped_ptrs<>. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix some gtk issues Created 7 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
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/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/process_util.h" 10 #include "base/process_util.h"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 } 56 }
57 57
58 // media::AudioOutputController::SyncReader implementations. 58 // media::AudioOutputController::SyncReader implementations.
59 void AudioSyncReader::UpdatePendingBytes(uint32 bytes) { 59 void AudioSyncReader::UpdatePendingBytes(uint32 bytes) {
60 if (bytes != static_cast<uint32>(media::kPauseMark)) { 60 if (bytes != static_cast<uint32>(media::kPauseMark)) {
61 // Store unknown length of data into buffer, so we later 61 // Store unknown length of data into buffer, so we later
62 // can find out if data became available. 62 // can find out if data became available.
63 media::SetUnknownDataSize(shared_memory_, packet_size_); 63 media::SetUnknownDataSize(shared_memory_, packet_size_);
64 } 64 }
65 65
66 if (socket_.get()) { 66 if (socket_) {
67 socket_->Send(&bytes, sizeof(bytes)); 67 socket_->Send(&bytes, sizeof(bytes));
68 } 68 }
69 } 69 }
70 70
71 int AudioSyncReader::Read(AudioBus* source, AudioBus* dest) { 71 int AudioSyncReader::Read(AudioBus* source, AudioBus* dest) {
72 ++renderer_callback_count_; 72 ++renderer_callback_count_;
73 if (!DataReady()) 73 if (!DataReady())
74 ++renderer_missed_callback_count_; 74 ++renderer_missed_callback_count_;
75 75
76 // Copy optional synchronized live audio input for consumption by renderer 76 // Copy optional synchronized live audio input for consumption by renderer
77 // process. 77 // process.
78 if (source && input_bus_.get()) { 78 if (source && input_bus_) {
79 DCHECK_EQ(source->channels(), input_bus_->channels()); 79 DCHECK_EQ(source->channels(), input_bus_->channels());
80 DCHECK_LE(source->frames(), input_bus_->frames()); 80 DCHECK_LE(source->frames(), input_bus_->frames());
81 source->CopyTo(input_bus_.get()); 81 source->CopyTo(input_bus_.get());
82 } 82 }
83 83
84 // Retrieve the actual number of bytes available from the shared memory. If 84 // Retrieve the actual number of bytes available from the shared memory. If
85 // the renderer has not completed rendering this value will be invalid (still 85 // the renderer has not completed rendering this value will be invalid (still
86 // the marker stored in UpdatePendingBytes() above) and must be sanitized. 86 // the marker stored in UpdatePendingBytes() above) and must be sanitized.
87 // TODO(dalecurtis): Technically this is not the exact size. Due to channel 87 // TODO(dalecurtis): Technically this is not the exact size. Due to channel
88 // padding for alignment, there may be more data available than this; AudioBus 88 // padding for alignment, there may be more data available than this; AudioBus
(...skipping 23 matching lines...) Expand all
112 112
113 // Store unknown length of data into buffer, in case renderer does not store 113 // Store unknown length of data into buffer, in case renderer does not store
114 // the length itself. It also helps in decision if we need to yield. 114 // the length itself. It also helps in decision if we need to yield.
115 media::SetUnknownDataSize(shared_memory_, packet_size_); 115 media::SetUnknownDataSize(shared_memory_, packet_size_);
116 116
117 // Return the actual number of frames read. 117 // Return the actual number of frames read.
118 return frames; 118 return frames;
119 } 119 }
120 120
121 void AudioSyncReader::Close() { 121 void AudioSyncReader::Close() {
122 if (socket_.get()) { 122 if (socket_) {
123 socket_->Close(); 123 socket_->Close();
124 } 124 }
125 } 125 }
126 126
127 bool AudioSyncReader::Init() { 127 bool AudioSyncReader::Init() {
128 socket_.reset(new base::CancelableSyncSocket()); 128 socket_.reset(new base::CancelableSyncSocket());
129 foreign_socket_.reset(new base::CancelableSyncSocket()); 129 foreign_socket_.reset(new base::CancelableSyncSocket());
130 return base::CancelableSyncSocket::CreatePair(socket_.get(), 130 return base::CancelableSyncSocket::CreatePair(socket_.get(),
131 foreign_socket_.get()); 131 foreign_socket_.get());
132 } 132 }
(...skipping 15 matching lines...) Expand all
148 base::FileDescriptor* foreign_handle) { 148 base::FileDescriptor* foreign_handle) {
149 foreign_handle->fd = foreign_socket_->handle(); 149 foreign_handle->fd = foreign_socket_->handle();
150 foreign_handle->auto_close = false; 150 foreign_handle->auto_close = false;
151 if (foreign_handle->fd != -1) 151 if (foreign_handle->fd != -1)
152 return true; 152 return true;
153 return false; 153 return false;
154 } 154 }
155 #endif 155 #endif
156 156
157 } // namespace content 157 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698