Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (C) 2013 Google Inc. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // | 2 // |
| 3 // Redistribution and use in source and binary forms, with or without | 3 // Redistribution and use in source and binary forms, with or without |
| 4 // modification, are permitted provided that the following conditions are | 4 // modification, are permitted provided that the following conditions are |
| 5 // met: | 5 // met: |
| 6 // | 6 // |
| 7 // * Redistributions of source code must retain the above copyright | 7 // * Redistributions of source code must retain the above copyright |
| 8 // notice, this list of conditions and the following disclaimer. | 8 // notice, this list of conditions and the following disclaimer. |
| 9 // * Redistributions in binary form must reproduce the above | 9 // * Redistributions in binary form must reproduce the above |
| 10 // copyright notice, this list of conditions and the following disclaimer | 10 // copyright notice, this list of conditions and the following disclaimer |
| 11 // in the documentation and/or other materials provided with the | 11 // in the documentation and/or other materials provided with the |
| 12 // distribution. | 12 // distribution. |
| 13 // * Neither the name of Google Inc. nor the names of its | 13 // * Neither the name of Google Inc. nor the names of its |
| 14 // contributors may be used to endorse or promote products derived from | 14 // contributors may be used to endorse or promote products derived from |
| 15 // this software without specific prior written permission. | 15 // this software without specific prior written permission. |
| 16 // | 16 // |
| 17 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 17 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 18 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 18 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 19 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 19 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 20 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 20 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 21 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 21 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 22 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 22 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 23 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 23 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 24 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 24 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 25 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 25 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 26 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 26 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 27 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 27 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 28 | 28 |
| 29 #ifndef GraphicsContextStateSaver_h | 29 #ifndef Spatializer_h |
| 30 #define GraphicsContextStateSaver_h | 30 #define Spatializer_h |
| 31 | 31 |
| 32 #include "platform/PlatformExport.h" | 32 #include "platform/PlatformExport.h" |
| 33 #include "platform/graphics/GraphicsContext.h" | 33 #include "platform/heap/Handle.h" |
| 34 | 34 |
| 35 namespace blink { | 35 namespace blink { |
| 36 | 36 |
| 37 class PLATFORM_EXPORT GraphicsContextStateSaver { | 37 class AudioBus; |
| 38 WTF_MAKE_FAST_ALLOCATED; | 38 |
| 39 // Abstract base class for spatializing a mono or stereo source. | |
| 40 class PLATFORM_EXPORT Spatializer : public GarbageCollectedFinalized<Spatializer > { | |
| 39 public: | 41 public: |
| 40 GraphicsContextStateSaver(GraphicsContext& context, bool saveAndRestore = tr ue) | 42 enum { |
| 41 : m_context(context) | 43 PanningModelEqualPower = 0, |
| 42 , m_saveAndRestore(saveAndRestore) | 44 PanningModelHRTF = 1, |
| 43 { | 45 PanningModelSurround = 2 |
|
Raymond Toy
2014/11/11 19:41:47
Are PanningModelHRTF and PanningModelSurround supp
hongchan
2014/11/12 00:06:54
Done.
| |
| 44 if (m_saveAndRestore) | 46 }; |
| 45 m_context.save(); | |
| 46 } | |
| 47 | 47 |
| 48 ~GraphicsContextStateSaver() | 48 typedef unsigned PanningModel; |
| 49 { | |
| 50 if (m_saveAndRestore) | |
| 51 m_context.restore(); | |
| 52 } | |
| 53 | 49 |
| 54 void save() | 50 static Spatializer* create(PanningModel, float sampleRate); |
| 55 { | |
| 56 ASSERT(!m_saveAndRestore); | |
| 57 m_context.save(); | |
| 58 m_saveAndRestore = true; | |
| 59 } | |
| 60 | 51 |
| 61 void saveIfNeeded() | 52 virtual ~Spatializer() { }; |
| 62 { | |
| 63 if (saved()) | |
| 64 return; | |
| 65 save(); | |
| 66 } | |
| 67 | 53 |
| 68 void restore() | 54 // Handle sample-accurate panning by AudioParam automation. |
| 69 { | 55 virtual void panWithSampleAccurateValues(const AudioBus* inputBus, AudioBus* outputBuf, const float* panValues, size_t framesToProcess) = 0; |
| 70 ASSERT(m_saveAndRestore); | |
| 71 m_context.restore(); | |
| 72 m_saveAndRestore = false; | |
| 73 } | |
| 74 | 56 |
| 75 GraphicsContext* context() const { return &m_context; } | 57 // Handle de-zippered panning to a target value. |
| 76 bool saved() const { return m_saveAndRestore; } | 58 virtual void panToTargetValue(const AudioBus* inputBus, AudioBus* outputBuf, float panValue, size_t framesToProcess) = 0; |
| 77 | 59 |
| 78 private: | 60 virtual void reset() = 0; |
| 79 GraphicsContext& m_context; | 61 virtual double tailTime() const = 0; |
| 80 bool m_saveAndRestore; | 62 virtual double latencyTime() const = 0; |
| 63 | |
| 64 virtual void trace(Visitor*) { } | |
| 65 | |
| 66 protected: | |
| 67 Spatializer(PanningModel model) { } | |
| 81 }; | 68 }; |
| 82 | 69 |
| 83 } // namespace blink | 70 } // namespace blink |
| 84 | 71 |
| 85 #endif // GraphicsContextStateSaver_h | 72 #endif // Spatializer_h |
| OLD | NEW |