Mac: Fix performance issues with remote CoreAnimation
[chromium-blink-merge.git] / components / copresence / test / audio_test_support.cc
blobb1913119e5fedbd364662cf592ea220286d11e66
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "components/copresence/test/audio_test_support.h"
7 #include <cstdlib>
9 #include "media/base/audio_bus.h"
11 namespace copresence {
13 void PopulateSamples(int random_seed, size_t size, float* samples) {
14 srand(random_seed);
15 for (size_t i = 0; i < size; ++i)
16 samples[i] = (2.0 * rand() / RAND_MAX) - 1;
19 scoped_ptr<media::AudioBus> CreateRandomAudio(int random_seed,
20 int channels,
21 int samples) {
22 scoped_ptr<media::AudioBus> bus = media::AudioBus::Create(channels, samples);
23 for (int ch = 0; ch < channels; ++ch)
24 PopulateSamples(random_seed, samples, bus->channel(ch));
25 return bus.Pass();
28 scoped_refptr<media::AudioBusRefCounted>
29 CreateRandomAudioRefCounted(int random_seed, int channels, int samples) {
30 scoped_refptr<media::AudioBusRefCounted> bus =
31 media::AudioBusRefCounted::Create(channels, samples);
32 for (int ch = 0; ch < channels; ++ch)
33 PopulateSamples(random_seed, samples, bus->channel(ch));
34 return bus;
37 } // namespace copresence