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

Side by Side Diff: components/audio_modem/test/random_samples.cc

Issue 1546143002: Switch to standard integer types in components/, part 1 of 4. (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 | « components/audio_modem/test/random_samples.h ('k') | components/audio_modem/test/stub_modem.h » ('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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "components/audio_modem/test/random_samples.h" 5 #include "components/audio_modem/test/random_samples.h"
6 6
7 #include <cstdlib> 7 #include <cstdlib>
8 8
9 #include "build/build_config.h"
9 #include "media/base/audio_bus.h" 10 #include "media/base/audio_bus.h"
10 11
11 namespace audio_modem { 12 namespace audio_modem {
12 13
13 void PopulateSamples(unsigned int random_seed, size_t size, float* samples) { 14 void PopulateSamples(unsigned int random_seed, size_t size, float* samples) {
14 // On Windows, rand() is threadsafe, and rand_r() is not available. 15 // On Windows, rand() is threadsafe, and rand_r() is not available.
15 #if defined(OS_WIN) 16 #if defined(OS_WIN)
16 srand(random_seed); 17 srand(random_seed);
17 for (size_t i = 0; i < size; ++i) 18 for (size_t i = 0; i < size; ++i)
18 samples[i] = (2.0 * rand() / RAND_MAX) - 1; // NOLINT 19 samples[i] = (2.0 * rand() / RAND_MAX) - 1; // NOLINT
19 #else 20 #else
20 for (size_t i = 0; i < size; ++i) 21 for (size_t i = 0; i < size; ++i)
21 samples[i] = (2.0 * rand_r(&random_seed) / RAND_MAX) - 1; 22 samples[i] = (2.0 * rand_r(&random_seed) / RAND_MAX) - 1;
22 #endif 23 #endif
23 } 24 }
24 25
25 scoped_refptr<media::AudioBusRefCounted> 26 scoped_refptr<media::AudioBusRefCounted>
26 CreateRandomAudioRefCounted(int random_seed, int channels, int samples) { 27 CreateRandomAudioRefCounted(int random_seed, int channels, int samples) {
27 scoped_refptr<media::AudioBusRefCounted> bus = 28 scoped_refptr<media::AudioBusRefCounted> bus =
28 media::AudioBusRefCounted::Create(channels, samples); 29 media::AudioBusRefCounted::Create(channels, samples);
29 for (int ch = 0; ch < channels; ++ch) 30 for (int ch = 0; ch < channels; ++ch)
30 PopulateSamples(random_seed, samples, bus->channel(ch)); 31 PopulateSamples(random_seed, samples, bus->channel(ch));
31 return bus; 32 return bus;
32 } 33 }
33 34
34 } // namespace audio_modem 35 } // namespace audio_modem
OLDNEW
« no previous file with comments | « components/audio_modem/test/random_samples.h ('k') | components/audio_modem/test/stub_modem.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698