OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 // A fake implementation of AudioOutputStream. It is used for testing purpose. | 5 // A fake implementation of AudioOutputStream. It is used for testing purpose. |
6 // TODO(hclam): Implement a thread in this fake output stream to simulate an | 6 // TODO(hclam): Implement a thread in this fake output stream to simulate an |
7 // audio output stream reading from AudioSourceCallback. | 7 // audio output stream reading from AudioSourceCallback. |
8 | 8 |
9 #ifndef MEDIA_AUDIO_FAKE_AUDIO_OUTPUT_STREAM_H_ | 9 #ifndef MEDIA_AUDIO_FAKE_AUDIO_OUTPUT_STREAM_H_ |
10 #define MEDIA_AUDIO_FAKE_AUDIO_OUTOUT_STREAM_H_ | 10 #define MEDIA_AUDIO_FAKE_AUDIO_OUTOUT_STREAM_H_ |
11 | 11 |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "base/scoped_ptr.h" | 14 #include "base/scoped_ptr.h" |
15 #include "media/audio/audio_output.h" | 15 #include "media/audio/audio_output.h" |
16 | 16 |
17 class FakeAudioOutputStream : public AudioOutputStream { | 17 class FakeAudioOutputStream : public AudioOutputStream { |
18 public: | 18 public: |
19 static AudioOutputStream* MakeFakeStream(); | 19 static AudioOutputStream* MakeFakeStream(); |
20 static FakeAudioOutputStream* GetLastFakeStream(); | 20 static FakeAudioOutputStream* GetLastFakeStream(); |
21 | 21 |
22 virtual bool Open(size_t packet_size); | 22 virtual bool Open(size_t packet_size); |
23 virtual void Start(AudioSourceCallback* callback); | 23 virtual void Start(AudioSourceCallback* callback); |
24 virtual void Stop(); | 24 virtual void Stop(); |
25 virtual void SetVolume(double left_level, double right_level); | 25 virtual void SetVolume(double volume); |
26 virtual void GetVolume(double* left_level, double* right_level); | 26 virtual void GetVolume(double* volume); |
27 virtual void Close(); | 27 virtual void Close(); |
28 | 28 |
29 char* buffer() { return buffer_.get(); } | 29 char* buffer() { return buffer_.get(); } |
30 double left_volume() { return left_volume_; } | 30 double volume() { return volume_; } |
31 double right_volume() { return right_volume_; } | |
32 | 31 |
33 private: | 32 private: |
34 FakeAudioOutputStream(); | 33 FakeAudioOutputStream(); |
35 virtual ~FakeAudioOutputStream() {} | 34 virtual ~FakeAudioOutputStream() {} |
36 | 35 |
37 static void DestroyLastFakeStream(void* param); | 36 static void DestroyLastFakeStream(void* param); |
38 static bool has_created_fake_stream_; | 37 static bool has_created_fake_stream_; |
39 static FakeAudioOutputStream* last_fake_stream_; | 38 static FakeAudioOutputStream* last_fake_stream_; |
40 | 39 |
41 double left_volume_; | 40 double volume_; |
42 double right_volume_; | |
43 AudioSourceCallback* callback_; | 41 AudioSourceCallback* callback_; |
44 scoped_array<char> buffer_; | 42 scoped_array<char> buffer_; |
45 size_t packet_size_; | 43 size_t packet_size_; |
46 | 44 |
47 DISALLOW_COPY_AND_ASSIGN(FakeAudioOutputStream); | 45 DISALLOW_COPY_AND_ASSIGN(FakeAudioOutputStream); |
48 }; | 46 }; |
49 | 47 |
50 #endif // MEDIA_AUDIO_FAKE_AUDIO_OUTPUT_STREAM_H_ | 48 #endif // MEDIA_AUDIO_FAKE_AUDIO_OUTPUT_STREAM_H_ |
| 49 |
OLD | NEW |