1 #ifndef SINE_SOURCE_H_
2 
3 #define SINE_SOURCE_H_
4 
5 #include <media/MediaSource.h>
6 #include <utils/Compat.h>
7 
8 namespace android {
9 
10 class MediaBufferGroup;
11 
12 struct SineSource : public MediaSource {
13     SineSource(int32_t sampleRate, int32_t numChannels);
14 
15     virtual status_t start(MetaData *params);
16     virtual status_t stop();
17 
18     virtual sp<MetaData> getFormat();
19 
20     virtual status_t read(
21             MediaBufferBase **out, const ReadOptions *options = NULL);
22 
23 protected:
24     virtual ~SineSource();
25 
26 private:
27     enum { kBufferSize = 8192 };
28     static const CONSTEXPR double kFrequency = 500.0;
29 
30     bool mStarted;
31     int32_t mSampleRate;
32     int32_t mNumChannels;
33     size_t mPhase;
34 
35     MediaBufferGroup *mGroup;
36 };
37 
38 }  // namespace android
39 
40 #endif // SINE_SOURCE_H_
41