blob: 4d3874d9ce0576d6795b624cb357fc70dfea25ae (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "media/audio/audio_output.h"
#include "testing/gtest/include/gtest/gtest.h"
class SimpleSource8bitStereo : public AudioOutputStream::AudioSourceCallback {
public:
explicit SimpleSource8bitStereo(size_t bytes_to_write)
: byte_count_(bytes_to_write), callback_count_(0) {
}
// AudioSourceCallback::OnMoreData implementation:
virtual size_t OnMoreData(AudioOutputStream* stream,
void* dest, size_t max_size) {
++callback_count_;
return byte_count_;
}
// AudioSourceCallback::OnClose implementation:
virtual void OnClose(AudioOutputStream* stream) {
}
// AudioSourceCallback::OnError implementation:
virtual void OnError(AudioOutputStream* stream, int code) {
}
// Returns how many times OnMoreData() has been called.
int callback_count() const {
return callback_count_;
}
private:
size_t byte_count_;
int callback_count_;
};
// Validate that the AudioManager::AUDIO_MOCK works.
TEST(WinAudioTest, MockStream) {
AudioManager* audio_man = GetAudioManager();
ASSERT_TRUE(NULL != audio_man);
AudioOutputStream* oas =
audio_man->MakeAudioStream(AudioManager::AUDIO_MOCK, 2, 8000, 8);
ASSERT_TRUE(NULL != oas);
EXPECT_TRUE(oas->Open(256));
SimpleSource8bitStereo source(256);
oas->Start(&source);
EXPECT_GT(source.callback_count(), 0);
oas->Close();
}
|