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

Unified Diff: Source/platform/audio/AudioDestination.h

Issue 100993004: Move chrome specific code from platform/audio/chromium to platform/audio (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: fixed atreat review commets Created 7 years 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 | « Source/platform/audio/AudioBus.cpp ('k') | Source/platform/audio/AudioDestination.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/audio/AudioDestination.h
diff --git a/Source/platform/audio/AudioDestination.h b/Source/platform/audio/AudioDestination.h
index 785d58c4551baa966806b68623a43d45f2aa2efa..07903ede316c29e4d671de786d1fb1645b02958b 100644
--- a/Source/platform/audio/AudioDestination.h
+++ b/Source/platform/audio/AudioDestination.h
@@ -29,33 +29,43 @@
#ifndef AudioDestination_h
#define AudioDestination_h
-#include "platform/PlatformExport.h"
-#include "wtf/OwnPtr.h"
-#include "wtf/PassOwnPtr.h"
+#include "platform/audio/AudioBus.h"
+#include "platform/audio/AudioIOCallback.h"
+#include "platform/audio/AudioSourceProvider.h"
+#include "public/platform/WebAudioDevice.h"
+#include "public/platform/WebVector.h"
+#include "wtf/Noncopyable.h"
#include "wtf/text/WTFString.h"
namespace WebCore {
-class AudioIOCallback;
+class AudioFIFO;
+class AudioPullFIFO;
-// AudioDestination is an abstraction for audio hardware I/O.
-// The audio hardware periodically calls the AudioIOCallback render() method asking it to render/output the next render quantum of audio.
-// It optionally will pass in local/live audio input when it calls render().
+// An AudioDestination using Chromium's audio system
-class PLATFORM_EXPORT AudioDestination {
+class PLATFORM_EXPORT AudioDestination : public blink::WebAudioDevice::RenderCallback, public AudioSourceProvider {
+ WTF_MAKE_NONCOPYABLE(AudioDestination);
public:
+ AudioDestination(AudioIOCallback&, const String& inputDeviceId, unsigned numberOfInputChannels, unsigned numberOfOutputChannels, float sampleRate);
+ virtual ~AudioDestination();
+
// Pass in (numberOfInputChannels > 0) if live/local audio input is desired.
// Port-specific device identification information for live/local input streams can be passed in the inputDeviceId.
static PassOwnPtr<AudioDestination> create(AudioIOCallback&, const String& inputDeviceId, unsigned numberOfInputChannels, unsigned numberOfOutputChannels, float sampleRate);
- virtual ~AudioDestination() { }
+ virtual void start();
+ virtual void stop();
+ bool isPlaying() { return m_isPlaying; }
+
+ float sampleRate() const { return m_sampleRate; }
+
+ // blink::WebAudioDevice::RenderCallback
+ virtual void render(const blink::WebVector<float*>& sourceData, const blink::WebVector<float*>& audioData, size_t numberOfFrames);
- virtual void start() = 0;
- virtual void stop() = 0;
- virtual bool isPlaying() = 0;
+ // WebCore::AudioSourceProvider
+ virtual void provideInput(AudioBus*, size_t framesToProcess);
- // Sample-rate conversion may happen in AudioDestination to the hardware sample-rate
- virtual float sampleRate() const = 0;
static float hardwareSampleRate();
// maxChannelCount() returns the total number of output channels of the audio hardware.
@@ -65,6 +75,19 @@ public:
// be a value: 1 <= numberOfOutputChannels <= maxChannelCount(),
// or if maxChannelCount() equals 0, then numberOfOutputChannels must be 2.
static unsigned long maxChannelCount();
+
+private:
+ AudioIOCallback& m_callback;
+ unsigned m_numberOfOutputChannels;
+ RefPtr<AudioBus> m_inputBus;
+ RefPtr<AudioBus> m_renderBus;
+ float m_sampleRate;
+ bool m_isPlaying;
+ OwnPtr<blink::WebAudioDevice> m_audioDevice;
+ size_t m_callbackBufferSize;
+
+ OwnPtr<AudioFIFO> m_inputFifo;
+ OwnPtr<AudioPullFIFO> m_fifo;
};
} // namespace WebCore
« no previous file with comments | « Source/platform/audio/AudioBus.cpp ('k') | Source/platform/audio/AudioDestination.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698