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

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

Issue 1544313002: Convert Pass()→std::move() in //media (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 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
« no previous file with comments | « media/audio/audio_output_device.cc ('k') | media/base/audio_shifter.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 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
9 #include <string> 8 #include <string>
9 #include <utility>
10 10
11 #include "base/cancelable_callback.h" 11 #include "base/cancelable_callback.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/single_thread_task_runner.h" 14 #include "base/single_thread_task_runner.h"
15 #include "base/synchronization/lock.h" 15 #include "base/synchronization/lock.h"
16 #include "base/time/time.h" 16 #include "base/time/time.h"
17 #include "media/audio/audio_manager.h" 17 #include "media/audio/audio_manager.h"
18 #include "media/audio/audio_manager_base.h" 18 #include "media/audio/audio_manager_base.h"
19 #include "media/audio/sounds/wav_audio_handler.h" 19 #include "media/audio/sounds/wav_audio_handler.h"
(...skipping 18 matching lines...) Expand all
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(scoped_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_(wav_audio.Pass()) { 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());
54 } 54 }
55 55
56 void Play() { 56 void Play() {
57 DCHECK(AudioManager::Get()->GetTaskRunner()->BelongsToCurrentThread()); 57 DCHECK(AudioManager::Get()->GetTaskRunner()->BelongsToCurrentThread());
58 58
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 AudioParameters::AUDIO_PCM_LOW_LATENCY, 181 AudioParameters::AUDIO_PCM_LOW_LATENCY,
182 GuessChannelLayout(wav_audio->num_channels()), wav_audio->sample_rate(), 182 GuessChannelLayout(wav_audio->num_channels()), wav_audio->sample_rate(),
183 wav_audio->bits_per_sample(), kDefaultFrameCount); 183 wav_audio->bits_per_sample(), kDefaultFrameCount);
184 if (!params.IsValid()) { 184 if (!params.IsValid()) {
185 LOG(ERROR) << "Audio params are invalid."; 185 LOG(ERROR) << "Audio params are invalid.";
186 return; 186 return;
187 } 187 }
188 188
189 // Store the duration of the WAV data then pass the handler to |stream_|. 189 // Store the duration of the WAV data then pass the handler to |stream_|.
190 duration_ = wav_audio->GetDuration(); 190 duration_ = wav_audio->GetDuration();
191 stream_.reset(new AudioStreamContainer(wav_audio.Pass())); 191 stream_.reset(new AudioStreamContainer(std::move(wav_audio)));
192 } 192 }
193 193
194 AudioStreamHandler::~AudioStreamHandler() { 194 AudioStreamHandler::~AudioStreamHandler() {
195 DCHECK(CalledOnValidThread()); 195 DCHECK(CalledOnValidThread());
196 if (IsInitialized()) { 196 if (IsInitialized()) {
197 AudioManager::Get()->GetTaskRunner()->PostTask( 197 AudioManager::Get()->GetTaskRunner()->PostTask(
198 FROM_HERE, base::Bind(&AudioStreamContainer::Stop, 198 FROM_HERE, base::Bind(&AudioStreamContainer::Stop,
199 base::Unretained(stream_.get()))); 199 base::Unretained(stream_.get())));
200 AudioManager::Get()->GetTaskRunner()->DeleteSoon(FROM_HERE, 200 AudioManager::Get()->GetTaskRunner()->DeleteSoon(FROM_HERE,
201 stream_.release()); 201 stream_.release());
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 g_observer_for_testing = observer; 241 g_observer_for_testing = observer;
242 } 242 }
243 243
244 // static 244 // static
245 void AudioStreamHandler::SetAudioSourceForTesting( 245 void AudioStreamHandler::SetAudioSourceForTesting(
246 AudioOutputStream::AudioSourceCallback* source) { 246 AudioOutputStream::AudioSourceCallback* source) {
247 g_audio_source_for_testing = source; 247 g_audio_source_for_testing = source;
248 } 248 }
249 249
250 } // namespace media 250 } // namespace media
OLDNEW
« no previous file with comments | « media/audio/audio_output_device.cc ('k') | media/base/audio_shifter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698