| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 public: | 54 public: |
| 55 static const double DefaultSmoothingConstant; | 55 static const double DefaultSmoothingConstant; |
| 56 static const double SnapThreshold; | 56 static const double SnapThreshold; |
| 57 | 57 |
| 58 static PassRefPtr<AudioParamHandler> create(AbstractAudioContext& context, d
ouble defaultValue) | 58 static PassRefPtr<AudioParamHandler> create(AbstractAudioContext& context, d
ouble defaultValue) |
| 59 { | 59 { |
| 60 return adoptRef(new AudioParamHandler(context, defaultValue)); | 60 return adoptRef(new AudioParamHandler(context, defaultValue)); |
| 61 } | 61 } |
| 62 | 62 |
| 63 // This should be used only in audio rendering thread. | 63 // This should be used only in audio rendering thread. |
| 64 AbstractAudioContext* context() const; | 64 AudioDestinationHandler& destinationHandler() const; |
| 65 | 65 |
| 66 // AudioSummingJunction | 66 // AudioSummingJunction |
| 67 void didUpdate() override { } | 67 void didUpdate() override { } |
| 68 | 68 |
| 69 AudioParamTimeline& timeline() { return m_timeline; } | 69 AudioParamTimeline& timeline() { return m_timeline; } |
| 70 | 70 |
| 71 // Intrinsic value. | 71 // Intrinsic value. |
| 72 float value(); | 72 float value(); |
| 73 void setValue(float); | 73 void setValue(float); |
| 74 | 74 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 100 void connect(AudioNodeOutput&); | 100 void connect(AudioNodeOutput&); |
| 101 void disconnect(AudioNodeOutput&); | 101 void disconnect(AudioNodeOutput&); |
| 102 | 102 |
| 103 float intrinsicValue() const { return noBarrierLoad(&m_intrinsicValue); } | 103 float intrinsicValue() const { return noBarrierLoad(&m_intrinsicValue); } |
| 104 private: | 104 private: |
| 105 AudioParamHandler(AbstractAudioContext& context, double defaultValue) | 105 AudioParamHandler(AbstractAudioContext& context, double defaultValue) |
| 106 : AudioSummingJunction(context.deferredTaskHandler()) | 106 : AudioSummingJunction(context.deferredTaskHandler()) |
| 107 , m_intrinsicValue(defaultValue) | 107 , m_intrinsicValue(defaultValue) |
| 108 , m_defaultValue(defaultValue) | 108 , m_defaultValue(defaultValue) |
| 109 , m_smoothedValue(defaultValue) | 109 , m_smoothedValue(defaultValue) |
| 110 , m_context(&context) { } | 110 , m_destinationHandler(context.destination()->audioDestinationHandler()) |
| 111 { } |
| 111 | 112 |
| 112 // sampleAccurate corresponds to a-rate (audio rate) vs. k-rate in the Web A
udio specification. | 113 // sampleAccurate corresponds to a-rate (audio rate) vs. k-rate in the Web A
udio specification. |
| 113 void calculateFinalValues(float* values, unsigned numberOfValues, bool sampl
eAccurate); | 114 void calculateFinalValues(float* values, unsigned numberOfValues, bool sampl
eAccurate); |
| 114 void calculateTimelineValues(float* values, unsigned numberOfValues); | 115 void calculateTimelineValues(float* values, unsigned numberOfValues); |
| 115 | 116 |
| 116 // Intrinsic value | 117 // Intrinsic value |
| 117 float m_intrinsicValue; | 118 float m_intrinsicValue; |
| 118 void setIntrinsicValue(float newValue) { noBarrierStore(&m_intrinsicValue, n
ewValue); } | 119 void setIntrinsicValue(float newValue) { noBarrierStore(&m_intrinsicValue, n
ewValue); } |
| 119 | 120 |
| 120 float m_defaultValue; | 121 float m_defaultValue; |
| 121 | 122 |
| 122 // Smoothing (de-zippering) | 123 // Smoothing (de-zippering) |
| 123 float m_smoothedValue; | 124 float m_smoothedValue; |
| 124 | 125 |
| 125 AudioParamTimeline m_timeline; | 126 AudioParamTimeline m_timeline; |
| 126 | 127 |
| 127 // We can't make this Persistent because of a reference cycle. It's safe to | 128 // The destination node used to get necessary information like the smaple ra
te and context time. |
| 128 // access this field only when we're rendering audio. | 129 RefPtr<AudioDestinationHandler> m_destinationHandler; |
| 129 UntracedMember<AbstractAudioContext> m_context; | |
| 130 }; | 130 }; |
| 131 | 131 |
| 132 // AudioParam class represents web-exposed AudioParam interface. | 132 // AudioParam class represents web-exposed AudioParam interface. |
| 133 class AudioParam final : public GarbageCollectedFinalized<AudioParam>, public Sc
riptWrappable { | 133 class AudioParam final : public GarbageCollectedFinalized<AudioParam>, public Sc
riptWrappable { |
| 134 DEFINE_WRAPPERTYPEINFO(); | 134 DEFINE_WRAPPERTYPEINFO(); |
| 135 public: | 135 public: |
| 136 static AudioParam* create(AbstractAudioContext&, double defaultValue); | 136 static AudioParam* create(AbstractAudioContext&, double defaultValue); |
| 137 DECLARE_TRACE(); | 137 DECLARE_TRACE(); |
| 138 // |handler| always returns a valid object. | 138 // |handler| always returns a valid object. |
| 139 AudioParamHandler& handler() const { return *m_handler; } | 139 AudioParamHandler& handler() const { return *m_handler; } |
| (...skipping 13 matching lines...) Expand all Loading... |
| 153 private: | 153 private: |
| 154 AudioParam(AbstractAudioContext&, double defaultValue); | 154 AudioParam(AbstractAudioContext&, double defaultValue); |
| 155 | 155 |
| 156 RefPtr<AudioParamHandler> m_handler; | 156 RefPtr<AudioParamHandler> m_handler; |
| 157 Member<AbstractAudioContext> m_context; | 157 Member<AbstractAudioContext> m_context; |
| 158 }; | 158 }; |
| 159 | 159 |
| 160 } // namespace blink | 160 } // namespace blink |
| 161 | 161 |
| 162 #endif // AudioParam_h | 162 #endif // AudioParam_h |
| OLD | NEW |