| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 11 matching lines...) Expand all Loading... |
| 22 }; | 22 }; |
| 23 // |channels| is the number of audio channels, |freq| is the frequency in | 23 // |channels| is the number of audio channels, |freq| is the frequency in |
| 24 // hertz and it has to be less than half of the sampling frequency | 24 // hertz and it has to be less than half of the sampling frequency |
| 25 // |sample_freq| or else you will get aliasing. | 25 // |sample_freq| or else you will get aliasing. |
| 26 SineWaveAudioSource(Format format, int channels, | 26 SineWaveAudioSource(Format format, int channels, |
| 27 double freq, double sample_freq); | 27 double freq, double sample_freq); |
| 28 virtual ~SineWaveAudioSource() {} | 28 virtual ~SineWaveAudioSource() {} |
| 29 | 29 |
| 30 // Implementation of AudioSourceCallback. | 30 // Implementation of AudioSourceCallback. |
| 31 virtual uint32 OnMoreData( | 31 virtual uint32 OnMoreData( |
| 32 AudioOutputStream* stream, uint8* dest, uint32 max_size, | 32 uint8* dest, uint32 max_size, AudioBuffersState audio_buffers) OVERRIDE; |
| 33 AudioBuffersState audio_buffers) OVERRIDE; | |
| 34 virtual void OnError(AudioOutputStream* stream, int code) OVERRIDE; | 33 virtual void OnError(AudioOutputStream* stream, int code) OVERRIDE; |
| 35 | 34 |
| 36 protected: | 35 protected: |
| 37 Format format_; | 36 Format format_; |
| 38 int channels_; | 37 int channels_; |
| 39 double freq_; | 38 double freq_; |
| 40 double sample_freq_; | 39 double sample_freq_; |
| 41 int time_state_; | 40 int time_state_; |
| 42 }; | 41 }; |
| 43 | 42 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 67 PushSource(); | 66 PushSource(); |
| 68 virtual ~PushSource(); | 67 virtual ~PushSource(); |
| 69 | 68 |
| 70 // Write one buffer. | 69 // Write one buffer. |
| 71 virtual bool Write(const void* data, uint32 len) OVERRIDE; | 70 virtual bool Write(const void* data, uint32 len) OVERRIDE; |
| 72 | 71 |
| 73 // Return the total number of bytes not given to the audio device yet. | 72 // Return the total number of bytes not given to the audio device yet. |
| 74 virtual uint32 UnProcessedBytes() OVERRIDE; | 73 virtual uint32 UnProcessedBytes() OVERRIDE; |
| 75 | 74 |
| 76 // Implementation of AudioSourceCallback. | 75 // Implementation of AudioSourceCallback. |
| 77 virtual uint32 OnMoreData(AudioOutputStream* stream, | 76 virtual uint32 OnMoreData(uint8* dest, |
| 78 uint8* dest, | |
| 79 uint32 max_size, | 77 uint32 max_size, |
| 80 AudioBuffersState buffers_state) OVERRIDE; | 78 AudioBuffersState buffers_state) OVERRIDE; |
| 81 virtual void OnError(AudioOutputStream* stream, int code) OVERRIDE; | 79 virtual void OnError(AudioOutputStream* stream, int code) OVERRIDE; |
| 82 | 80 |
| 83 // Discard all buffered data and reset to initial state. | 81 // Discard all buffered data and reset to initial state. |
| 84 void ClearAll(); | 82 void ClearAll(); |
| 85 | 83 |
| 86 private: | 84 private: |
| 87 // Free acquired resources. | 85 // Free acquired resources. |
| 88 void CleanUp(); | 86 void CleanUp(); |
| 89 | 87 |
| 90 media::SeekableBuffer buffer_; | 88 media::SeekableBuffer buffer_; |
| 91 }; | 89 }; |
| 92 | 90 |
| 93 } // namespace media | 91 } // namespace media |
| 94 | 92 |
| 95 #endif // MEDIA_AUDIO_SIMPLE_SOURCES_H_ | 93 #endif // MEDIA_AUDIO_SIMPLE_SOURCES_H_ |
| OLD | NEW |