Chromium Code Reviews| Index: Source/platform/audio/Spatializer.h |
| diff --git a/Source/platform/graphics/GraphicsContextStateSaver.h b/Source/platform/audio/Spatializer.h |
| similarity index 57% |
| copy from Source/platform/graphics/GraphicsContextStateSaver.h |
| copy to Source/platform/audio/Spatializer.h |
| index 7134a98d938e44a9e0041b120a4cebc24238a54d..ce9d28e6b4be43e6591ca95816e9f66f6bc79019 100644 |
| --- a/Source/platform/graphics/GraphicsContextStateSaver.h |
| +++ b/Source/platform/audio/Spatializer.h |
| @@ -1,4 +1,4 @@ |
| -// Copyright (C) 2013 Google Inc. All rights reserved. |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| // |
| // Redistribution and use in source and binary forms, with or without |
| // modification, are permitted provided that the following conditions are |
| @@ -26,60 +26,47 @@ |
| // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| -#ifndef GraphicsContextStateSaver_h |
| -#define GraphicsContextStateSaver_h |
| +#ifndef Spatializer_h |
| +#define Spatializer_h |
| #include "platform/PlatformExport.h" |
| -#include "platform/graphics/GraphicsContext.h" |
| +#include "platform/heap/Handle.h" |
| namespace blink { |
| -class PLATFORM_EXPORT GraphicsContextStateSaver { |
| - WTF_MAKE_FAST_ALLOCATED; |
| +class AudioBus; |
| + |
| +// Abstract base class for spatializing a mono or stereo source. |
| +class PLATFORM_EXPORT Spatializer : public GarbageCollectedFinalized<Spatializer> { |
| public: |
| - GraphicsContextStateSaver(GraphicsContext& context, bool saveAndRestore = true) |
| - : m_context(context) |
| - , m_saveAndRestore(saveAndRestore) |
| - { |
| - if (m_saveAndRestore) |
| - m_context.save(); |
| - } |
| + enum { |
| + PanningModelEqualPower = 0, |
| + PanningModelHRTF = 1, |
| + PanningModelSurround = 2 |
|
Raymond Toy
2014/11/11 19:41:47
Are PanningModelHRTF and PanningModelSurround supp
hongchan
2014/11/12 00:06:54
Done.
|
| + }; |
| + |
| + typedef unsigned PanningModel; |
| + |
| + static Spatializer* create(PanningModel, float sampleRate); |
| - ~GraphicsContextStateSaver() |
| - { |
| - if (m_saveAndRestore) |
| - m_context.restore(); |
| - } |
| + virtual ~Spatializer() { }; |
| - void save() |
| - { |
| - ASSERT(!m_saveAndRestore); |
| - m_context.save(); |
| - m_saveAndRestore = true; |
| - } |
| + // Handle sample-accurate panning by AudioParam automation. |
| + virtual void panWithSampleAccurateValues(const AudioBus* inputBus, AudioBus* outputBuf, const float* panValues, size_t framesToProcess) = 0; |
| - void saveIfNeeded() |
| - { |
| - if (saved()) |
| - return; |
| - save(); |
| - } |
| + // Handle de-zippered panning to a target value. |
| + virtual void panToTargetValue(const AudioBus* inputBus, AudioBus* outputBuf, float panValue, size_t framesToProcess) = 0; |
| - void restore() |
| - { |
| - ASSERT(m_saveAndRestore); |
| - m_context.restore(); |
| - m_saveAndRestore = false; |
| - } |
| + virtual void reset() = 0; |
| + virtual double tailTime() const = 0; |
| + virtual double latencyTime() const = 0; |
| - GraphicsContext* context() const { return &m_context; } |
| - bool saved() const { return m_saveAndRestore; } |
| + virtual void trace(Visitor*) { } |
| -private: |
| - GraphicsContext& m_context; |
| - bool m_saveAndRestore; |
| +protected: |
| + Spatializer(PanningModel model) { } |
| }; |
| } // namespace blink |
| -#endif // GraphicsContextStateSaver_h |
| +#endif // Spatializer_h |