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

Side by Side Diff: media/audio/mac/audio_low_latency_input_mac_unittest.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: Fix cast + windows build 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 (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 <stdint.h> 5 #include <stdint.h>
6 6
7 #include "base/environment.h" 7 #include "base/environment.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "base/test/test_timeouts.h" 10 #include "base/test/test_timeouts.h"
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 } 75 }
76 fclose(file_); 76 fclose(file_);
77 } 77 }
78 78
79 // AudioInputStream::AudioInputCallback implementation. 79 // AudioInputStream::AudioInputCallback implementation.
80 void OnData(AudioInputStream* stream, 80 void OnData(AudioInputStream* stream,
81 const AudioBus* src, 81 const AudioBus* src,
82 uint32_t hardware_delay_bytes, 82 uint32_t hardware_delay_bytes,
83 double volume) override { 83 double volume) override {
84 const int num_samples = src->frames() * src->channels(); 84 const int num_samples = src->frames() * src->channels();
85 scoped_ptr<int16_t> interleaved(new int16_t[num_samples]); 85 std::unique_ptr<int16_t> interleaved(new int16_t[num_samples]);
danakj 2016/04/22 22:47:37 include memory
dcheng 2016/04/22 23:13:20 Done.
86 const int bytes_per_sample = sizeof(*interleaved); 86 const int bytes_per_sample = sizeof(*interleaved);
87 src->ToInterleaved(src->frames(), bytes_per_sample, interleaved.get()); 87 src->ToInterleaved(src->frames(), bytes_per_sample, interleaved.get());
88 88
89 // Store data data in a temporary buffer to avoid making blocking 89 // Store data data in a temporary buffer to avoid making blocking
90 // fwrite() calls in the audio callback. The complete buffer will be 90 // fwrite() calls in the audio callback. The complete buffer will be
91 // written to file in the destructor. 91 // written to file in the destructor.
92 const int size = bytes_per_sample * num_samples; 92 const int size = bytes_per_sample * num_samples;
93 if (buffer_.Append((const uint8_t*)interleaved.get(), size)) { 93 if (buffer_.Append((const uint8_t*)interleaved.get(), size)) {
94 bytes_to_write_ += size; 94 bytes_to_write_ += size;
95 } 95 }
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 WriteToFileAudioSink file_sink(file_name); 267 WriteToFileAudioSink file_sink(file_name);
268 fprintf(stderr, " >> Speak into the mic while recording...\n"); 268 fprintf(stderr, " >> Speak into the mic while recording...\n");
269 ais->Start(&file_sink); 269 ais->Start(&file_sink);
270 base::PlatformThread::Sleep(TestTimeouts::action_timeout()); 270 base::PlatformThread::Sleep(TestTimeouts::action_timeout());
271 ais->Stop(); 271 ais->Stop();
272 fprintf(stderr, " >> Recording has stopped.\n"); 272 fprintf(stderr, " >> Recording has stopped.\n");
273 ais->Close(); 273 ais->Close();
274 } 274 }
275 275
276 } // namespace media 276 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698