summaryrefslogtreecommitdiffstats
path: root/media/audio/simple_sources.h
diff options
context:
space:
mode:
authorcpu@google.com <cpu@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-01-05 20:37:11 +0000
committercpu@google.com <cpu@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-01-05 20:37:11 +0000
commitf8edbfe65440706c0508b634f3ccc7b146ee7348 (patch)
tree2d88944f512748d8fda60dd59596dc9ddaf8a083 /media/audio/simple_sources.h
parent50c72e99ae54ff90523ac9f52cb663fce115c9d6 (diff)
downloadchromium_src-f8edbfe65440706c0508b634f3ccc7b146ee7348.zip
chromium_src-f8edbfe65440706c0508b634f3ccc7b146ee7348.tar.gz
chromium_src-f8edbfe65440706c0508b634f3ccc7b146ee7348.tar.bz2
A simple tone source useful for testing and troubleshooting
- Only windows 16 PCM mono implementation so far. Review URL: http://codereview.chromium.org/16226 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@7557 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/audio/simple_sources.h')
-rw-r--r--media/audio/simple_sources.h40
1 files changed, 40 insertions, 0 deletions
diff --git a/media/audio/simple_sources.h b/media/audio/simple_sources.h
new file mode 100644
index 0000000..992aba5
--- /dev/null
+++ b/media/audio/simple_sources.h
@@ -0,0 +1,40 @@
+// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef MEDIA_AUDIO_SIMPLE_SOURCES_H_
+#define MEDIA_AUDIO_SIMPLE_SOURCES_H_
+
+#include "media/audio/audio_output.h"
+
+// An audio source that produces a pure sinusoidal tone. Each platform needs
+// a slightly different implementation because it needs to handle the native
+// audio buffer format.
+class SineWaveAudioSource : public AudioOutputStream::AudioSourceCallback {
+ public:
+ enum Format {
+ FORMAT_8BIT_LINEAR_PCM,
+ FORMAT_16BIT_LINEAR_PCM,
+ };
+
+ // |channels| is the number of audio channels, |freq| is the frequency in
+ // hertz and it has to be less than half of the sampling frequency
+ // |sample_freq| or else you will get aliasing.
+ SineWaveAudioSource(Format format, int channels,
+ double freq, double sample_freq);
+ virtual ~SineWaveAudioSource() {}
+
+ // Implementation of AudioSourceCallback.
+ virtual size_t OnMoreData(AudioOutputStream* stream,
+ void* dest, size_t max_size);
+ virtual void OnClose(AudioOutputStream* stream);
+ virtual void OnError(AudioOutputStream* stream, int code);
+
+ protected:
+ Format format_;
+ int channels_;
+ double freq_;
+ double sample_freq_;
+};
+
+#endif // MEDIA_AUDIO_SIMPLE_SOURCES_H_