OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 // |
| 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 |
| 7 // audio output stream reading from AudioSourceCallback. |
| 8 |
| 9 #ifndef MEDIA_AUDIO_FAKE_AUDIO_OUTPUT_STREAM_H_ |
| 10 #define MEDIA_AUDIO_FAKE_AUDIO_OUTOUT_STREAM_H_ |
| 11 |
| 12 #include <vector> |
| 13 |
| 14 #include "base/scoped_ptr.h" |
| 15 #include "media/audio/audio_output.h" |
| 16 |
| 17 class FakeAudioOutputStream : public AudioOutputStream { |
| 18 public: |
| 19 static AudioOutputStream* MakeFakeStream(); |
| 20 static FakeAudioOutputStream* GetLastFakeStream(); |
| 21 |
| 22 virtual bool Open(size_t packet_size); |
| 23 virtual void Start(AudioSourceCallback* callback); |
| 24 virtual void Stop(); |
| 25 virtual void SetVolume(double left_level, double right_level); |
| 26 virtual void GetVolume(double* left_level, double* right_level); |
| 27 virtual void Close(); |
| 28 |
| 29 char* buffer() { return buffer_.get(); } |
| 30 double left_volume() { return left_volume_; } |
| 31 double right_volume() { return right_volume_; } |
| 32 |
| 33 private: |
| 34 FakeAudioOutputStream(); |
| 35 virtual ~FakeAudioOutputStream() {} |
| 36 |
| 37 static void DestroyLastFakeStream(void* param); |
| 38 static bool has_created_fake_stream_; |
| 39 static FakeAudioOutputStream* last_fake_stream_; |
| 40 |
| 41 double left_volume_; |
| 42 double right_volume_; |
| 43 AudioSourceCallback* callback_; |
| 44 scoped_ptr_malloc<char> buffer_; |
| 45 size_t packet_size_; |
| 46 |
| 47 DISALLOW_COPY_AND_ASSIGN(FakeAudioOutputStream); |
| 48 }; |
| 49 |
| 50 #endif // MEDIA_AUDIO_FAKE_AUDIO_OUTPUT_STREAM_H_ |
OLD | NEW |