OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "media/audio/audio_io.h" | 10 #include "media/audio/audio_io.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 // |channels| is the number of audio channels, |freq| is the frequency in | 21 // |channels| is the number of audio channels, |freq| is the frequency in |
22 // hertz and it has to be less than half of the sampling frequency | 22 // hertz and it has to be less than half of the sampling frequency |
23 // |sample_freq| or else you will get aliasing. | 23 // |sample_freq| or else you will get aliasing. |
24 SineWaveAudioSource(Format format, int channels, | 24 SineWaveAudioSource(Format format, int channels, |
25 double freq, double sample_freq); | 25 double freq, double sample_freq); |
26 virtual ~SineWaveAudioSource() {} | 26 virtual ~SineWaveAudioSource() {} |
27 | 27 |
28 // Implementation of AudioSourceCallback. | 28 // Implementation of AudioSourceCallback. |
29 virtual uint32 OnMoreData( | 29 virtual uint32 OnMoreData( |
30 AudioOutputStream* stream, uint8* dest, uint32 max_size, | 30 AudioOutputStream* stream, uint8* dest, uint32 max_size, |
31 AudioBuffersState audio_buffers); | 31 AudioBuffersState audio_buffers) OVERRIDE; |
32 virtual void OnError(AudioOutputStream* stream, int code); | 32 virtual void OnError(AudioOutputStream* stream, int code) OVERRIDE; |
33 | 33 |
34 protected: | 34 protected: |
35 Format format_; | 35 Format format_; |
36 int channels_; | 36 int channels_; |
37 double freq_; | 37 double freq_; |
38 double sample_freq_; | 38 double sample_freq_; |
39 }; | 39 }; |
40 | 40 |
41 // Defines an interface for pushing audio output. In contrast, the interfaces | 41 // Defines an interface for pushing audio output. In contrast, the interfaces |
42 // defined by AudioSourceCallback are pull model only. | 42 // defined by AudioSourceCallback are pull model only. |
(...skipping 15 matching lines...) Expand all Loading... |
58 // of audio buffers and is unaware of the actual audio format. | 58 // of audio buffers and is unaware of the actual audio format. |
59 // Note that the PushSource is not thread safe and user need to provide locking. | 59 // Note that the PushSource is not thread safe and user need to provide locking. |
60 class MEDIA_EXPORT PushSource | 60 class MEDIA_EXPORT PushSource |
61 : public AudioOutputStream::AudioSourceCallback, | 61 : public AudioOutputStream::AudioSourceCallback, |
62 public PushAudioOutput { | 62 public PushAudioOutput { |
63 public: | 63 public: |
64 PushSource(); | 64 PushSource(); |
65 virtual ~PushSource(); | 65 virtual ~PushSource(); |
66 | 66 |
67 // Write one buffer. | 67 // Write one buffer. |
68 virtual bool Write(const void* data, uint32 len); | 68 virtual bool Write(const void* data, uint32 len) OVERRIDE; |
69 | 69 |
70 // Return the total number of bytes not given to the audio device yet. | 70 // Return the total number of bytes not given to the audio device yet. |
71 virtual uint32 UnProcessedBytes(); | 71 virtual uint32 UnProcessedBytes() OVERRIDE; |
72 | 72 |
73 // Implementation of AudioSourceCallback. | 73 // Implementation of AudioSourceCallback. |
74 virtual uint32 OnMoreData(AudioOutputStream* stream, uint8* dest, | 74 virtual uint32 OnMoreData(AudioOutputStream* stream, |
75 uint32 max_size, AudioBuffersState buffers_state); | 75 uint8* dest, |
76 virtual void OnError(AudioOutputStream* stream, int code); | 76 uint32 max_size, |
| 77 AudioBuffersState buffers_state) OVERRIDE; |
| 78 virtual void OnError(AudioOutputStream* stream, int code) OVERRIDE; |
77 | 79 |
78 // Discard all buffered data and reset to initial state. | 80 // Discard all buffered data and reset to initial state. |
79 void ClearAll(); | 81 void ClearAll(); |
80 | 82 |
81 private: | 83 private: |
82 // Free acquired resources. | 84 // Free acquired resources. |
83 void CleanUp(); | 85 void CleanUp(); |
84 | 86 |
85 media::SeekableBuffer buffer_; | 87 media::SeekableBuffer buffer_; |
86 }; | 88 }; |
87 | 89 |
88 #endif // MEDIA_AUDIO_SIMPLE_SOURCES_H_ | 90 #endif // MEDIA_AUDIO_SIMPLE_SOURCES_H_ |
OLD | NEW |