Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(128)

Unified Diff: media/audio/simple_sources.h

Issue 10832285: Switch OnMoreData() to use AudioBus. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase. Comments. Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/audio/pulse/pulse_output.cc ('k') | media/audio/simple_sources.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/audio/simple_sources.h
diff --git a/media/audio/simple_sources.h b/media/audio/simple_sources.h
index f68c2bec4e9f7cfbb33b3fc4e7f840835fff7c10..5fbcded9ff39986df2d8e753cc12305b749ee223 100644
--- a/media/audio/simple_sources.h
+++ b/media/audio/simple_sources.h
@@ -5,8 +5,7 @@
#ifndef MEDIA_AUDIO_SIMPLE_SOURCES_H_
#define MEDIA_AUDIO_SIMPLE_SOURCES_H_
-#include <list>
-
+#include "base/synchronization/lock.h"
#include "media/audio/audio_io.h"
#include "media/base/seekable_buffer.h"
@@ -16,73 +15,28 @@ namespace media {
class MEDIA_EXPORT 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);
+ SineWaveAudioSource(int channels, double freq, double sample_freq);
virtual ~SineWaveAudioSource() {}
+ // Return up to |cap| samples of data via OnMoreData(). Use Reset() to
+ // allow more data to be served.
+ void CapSamples(int cap);
+ void Reset();
+
// Implementation of AudioSourceCallback.
- virtual uint32 OnMoreData(
- uint8* dest, uint32 max_size, AudioBuffersState audio_buffers) OVERRIDE;
+ virtual int OnMoreData(AudioBus* audio_bus,
+ AudioBuffersState audio_buffers) OVERRIDE;
virtual void OnError(AudioOutputStream* stream, int code) OVERRIDE;
protected:
- Format format_;
int channels_;
- double freq_;
- double sample_freq_;
+ double f_;
int time_state_;
-};
-
-// Defines an interface for pushing audio output. In contrast, the interfaces
-// defined by AudioSourceCallback are pull model only.
-class MEDIA_EXPORT PushAudioOutput {
- public:
- virtual ~PushAudioOutput() {}
-
- // Write audio data to the audio device. It will be played eventually.
- // Returns false on failure.
- virtual bool Write(const void* data, uint32 len) = 0;
-
- // Returns the number of bytes that have been buffered but not yet given
- // to the audio device.
- virtual uint32 UnProcessedBytes() = 0;
-};
-
-// A fairly basic class to connect a push model provider PushAudioOutput to
-// a pull model provider AudioSourceCallback. Fundamentally it manages a series
-// of audio buffers and is unaware of the actual audio format.
-// Note that the PushSource is not thread safe and user need to provide locking.
-class MEDIA_EXPORT PushSource
- : public AudioOutputStream::AudioSourceCallback,
- public PushAudioOutput {
- public:
- PushSource();
- virtual ~PushSource();
-
- // Write one buffer.
- virtual bool Write(const void* data, uint32 len) OVERRIDE;
-
- // Return the total number of bytes not given to the audio device yet.
- virtual uint32 UnProcessedBytes() OVERRIDE;
-
- // Implementation of AudioSourceCallback.
- virtual uint32 OnMoreData(uint8* dest,
- uint32 max_size,
- AudioBuffersState buffers_state) OVERRIDE;
- virtual void OnError(AudioOutputStream* stream, int code) OVERRIDE;
-
- private:
- // Free acquired resources.
- void CleanUp();
-
- media::SeekableBuffer buffer_;
+ int cap_;
+ base::Lock time_lock_;
};
} // namespace media
« no previous file with comments | « media/audio/pulse/pulse_output.cc ('k') | media/audio/simple_sources.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698