OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #ifndef MEDIA_AUDIO_SIMPLE_SOURCES_H_ | 5 #ifndef MEDIA_AUDIO_SIMPLE_SOURCES_H_ |
6 #define MEDIA_AUDIO_SIMPLE_SOURCES_H_ | 6 #define MEDIA_AUDIO_SIMPLE_SOURCES_H_ |
7 | 7 |
8 #include <list> | 8 #include <list> |
9 | 9 |
10 #include "base/lock.h" | |
11 #include "media/audio/audio_io.h" | 10 #include "media/audio/audio_io.h" |
12 #include "media/base/seekable_buffer.h" | 11 #include "media/base/seekable_buffer.h" |
13 | 12 |
14 // An audio source that produces a pure sinusoidal tone. | 13 // An audio source that produces a pure sinusoidal tone. |
15 class SineWaveAudioSource : public AudioOutputStream::AudioSourceCallback { | 14 class SineWaveAudioSource : public AudioOutputStream::AudioSourceCallback { |
16 public: | 15 public: |
17 enum Format { | 16 enum Format { |
18 FORMAT_8BIT_LINEAR_PCM, | 17 FORMAT_8BIT_LINEAR_PCM, |
19 FORMAT_16BIT_LINEAR_PCM, | 18 FORMAT_16BIT_LINEAR_PCM, |
20 }; | 19 }; |
(...skipping 14 matching lines...) Expand all Loading... |
35 Format format_; | 34 Format format_; |
36 int channels_; | 35 int channels_; |
37 double freq_; | 36 double freq_; |
38 double sample_freq_; | 37 double sample_freq_; |
39 }; | 38 }; |
40 | 39 |
41 // Defines an interface for pushing audio output. In contrast, the interfaces | 40 // Defines an interface for pushing audio output. In contrast, the interfaces |
42 // defined by AudioSourceCallback are pull model only. | 41 // defined by AudioSourceCallback are pull model only. |
43 class PushAudioOutput { | 42 class PushAudioOutput { |
44 public: | 43 public: |
45 virtual ~PushAudioOutput(){} | 44 virtual ~PushAudioOutput() {} |
46 | 45 |
47 // Write audio data to the audio device. It will be played eventually. | 46 // Write audio data to the audio device. It will be played eventually. |
48 // Returns false on failure. | 47 // Returns false on failure. |
49 virtual bool Write(const void* data, uint32 len) = 0; | 48 virtual bool Write(const void* data, uint32 len) = 0; |
50 | 49 |
51 // Returns the number of bytes that have been buffered but not yet given | 50 // Returns the number of bytes that have been buffered but not yet given |
52 // to the audio device. | 51 // to the audio device. |
53 virtual uint32 UnProcessedBytes() = 0; | 52 virtual uint32 UnProcessedBytes() = 0; |
54 }; | 53 }; |
55 | 54 |
(...skipping 22 matching lines...) Expand all Loading... |
78 void ClearAll(); | 77 void ClearAll(); |
79 | 78 |
80 private: | 79 private: |
81 // Free acquired resources. | 80 // Free acquired resources. |
82 void CleanUp(); | 81 void CleanUp(); |
83 | 82 |
84 media::SeekableBuffer buffer_; | 83 media::SeekableBuffer buffer_; |
85 }; | 84 }; |
86 | 85 |
87 #endif // MEDIA_AUDIO_SIMPLE_SOURCES_H_ | 86 #endif // MEDIA_AUDIO_SIMPLE_SOURCES_H_ |
OLD | NEW |