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

Side by Side Diff: media/audio/sounds/audio_stream_handler.cc

Issue 1911913002: Convert //media/audio from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "media/audio/sounds/audio_stream_handler.h" 5 #include "media/audio/sounds/audio_stream_handler.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 22 matching lines...) Expand all
33 const int kKeepAliveMs = 1500; 33 const int kKeepAliveMs = 1500;
34 34
35 AudioStreamHandler::TestObserver* g_observer_for_testing = NULL; 35 AudioStreamHandler::TestObserver* g_observer_for_testing = NULL;
36 AudioOutputStream::AudioSourceCallback* g_audio_source_for_testing = NULL; 36 AudioOutputStream::AudioSourceCallback* g_audio_source_for_testing = NULL;
37 37
38 } // namespace 38 } // namespace
39 39
40 class AudioStreamHandler::AudioStreamContainer 40 class AudioStreamHandler::AudioStreamContainer
41 : public AudioOutputStream::AudioSourceCallback { 41 : public AudioOutputStream::AudioSourceCallback {
42 public: 42 public:
43 explicit AudioStreamContainer(scoped_ptr<WavAudioHandler> wav_audio) 43 explicit AudioStreamContainer(std::unique_ptr<WavAudioHandler> wav_audio)
44 : started_(false), 44 : started_(false),
45 stream_(NULL), 45 stream_(NULL),
46 cursor_(0), 46 cursor_(0),
47 delayed_stop_posted_(false), 47 delayed_stop_posted_(false),
48 wav_audio_(std::move(wav_audio)) { 48 wav_audio_(std::move(wav_audio)) {
49 DCHECK(wav_audio_); 49 DCHECK(wav_audio_);
50 } 50 }
51 51
52 ~AudioStreamContainer() override { 52 ~AudioStreamContainer() override {
53 DCHECK(AudioManager::Get()->GetTaskRunner()->BelongsToCurrentThread()); 53 DCHECK(AudioManager::Get()->GetTaskRunner()->BelongsToCurrentThread());
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 } 151 }
152 152
153 // Must only be accessed on the AudioManager::GetTaskRunner() thread. 153 // Must only be accessed on the AudioManager::GetTaskRunner() thread.
154 bool started_; 154 bool started_;
155 AudioOutputStream* stream_; 155 AudioOutputStream* stream_;
156 156
157 // All variables below must be accessed under |state_lock_| when |started_|. 157 // All variables below must be accessed under |state_lock_| when |started_|.
158 base::Lock state_lock_; 158 base::Lock state_lock_;
159 size_t cursor_; 159 size_t cursor_;
160 bool delayed_stop_posted_; 160 bool delayed_stop_posted_;
161 scoped_ptr<WavAudioHandler> wav_audio_; 161 std::unique_ptr<WavAudioHandler> wav_audio_;
162 base::CancelableClosure stop_closure_; 162 base::CancelableClosure stop_closure_;
163 163
164 DISALLOW_COPY_AND_ASSIGN(AudioStreamContainer); 164 DISALLOW_COPY_AND_ASSIGN(AudioStreamContainer);
165 }; 165 };
166 166
167 AudioStreamHandler::AudioStreamHandler(const base::StringPiece& wav_data) { 167 AudioStreamHandler::AudioStreamHandler(const base::StringPiece& wav_data) {
168 AudioManager* manager = AudioManager::Get(); 168 AudioManager* manager = AudioManager::Get();
169 if (!manager) { 169 if (!manager) {
170 LOG(ERROR) << "Can't get access to audio manager."; 170 LOG(ERROR) << "Can't get access to audio manager.";
171 return; 171 return;
172 } 172 }
173 173
174 scoped_ptr<WavAudioHandler> wav_audio = WavAudioHandler::Create(wav_data); 174 std::unique_ptr<WavAudioHandler> wav_audio =
175 WavAudioHandler::Create(wav_data);
175 if (!wav_audio) { 176 if (!wav_audio) {
176 LOG(ERROR) << "wav_data is not valid"; 177 LOG(ERROR) << "wav_data is not valid";
177 return; 178 return;
178 } 179 }
179 180
180 const AudioParameters params( 181 const AudioParameters params(
181 AudioParameters::AUDIO_PCM_LOW_LATENCY, 182 AudioParameters::AUDIO_PCM_LOW_LATENCY,
182 GuessChannelLayout(wav_audio->num_channels()), wav_audio->sample_rate(), 183 GuessChannelLayout(wav_audio->num_channels()), wav_audio->sample_rate(),
183 wav_audio->bits_per_sample(), kDefaultFrameCount); 184 wav_audio->bits_per_sample(), kDefaultFrameCount);
184 if (!params.IsValid()) { 185 if (!params.IsValid()) {
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 g_observer_for_testing = observer; 242 g_observer_for_testing = observer;
242 } 243 }
243 244
244 // static 245 // static
245 void AudioStreamHandler::SetAudioSourceForTesting( 246 void AudioStreamHandler::SetAudioSourceForTesting(
246 AudioOutputStream::AudioSourceCallback* source) { 247 AudioOutputStream::AudioSourceCallback* source) {
247 g_audio_source_for_testing = source; 248 g_audio_source_for_testing = source;
248 } 249 }
249 250
250 } // namespace media 251 } // namespace media
OLDNEW
« no previous file with comments | « media/audio/sounds/audio_stream_handler.h ('k') | media/audio/sounds/audio_stream_handler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698