OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011, Google Inc. All rights reserved. | 2 * Copyright (C) 2011, 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 * 1. Redistributions of source code must retain the above copyright | 7 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 exception_state.ThrowDOMException( | 85 exception_state.ThrowDOMException( |
86 kInvalidAccessError, | 86 kInvalidAccessError, |
87 ExceptionMessages::IndexExceedsMinimumBound<unsigned>("curve length", | 87 ExceptionMessages::IndexExceedsMinimumBound<unsigned>("curve length", |
88 curve_length, 2)); | 88 curve_length, 2)); |
89 return; | 89 return; |
90 } | 90 } |
91 | 91 |
92 GetWaveShaperProcessor()->SetCurve(curve_data, curve_length); | 92 GetWaveShaperProcessor()->SetCurve(curve_data, curve_length); |
93 } | 93 } |
94 | 94 |
95 void WaveShaperNode::setCurve(NotShared<DOMFloat32Array> curve, | 95 void WaveShaperNode::setCurve(DOMFloat32Array* curve, |
96 ExceptionState& exception_state) { | 96 ExceptionState& exception_state) { |
97 DCHECK(IsMainThread()); | 97 DCHECK(IsMainThread()); |
98 | 98 |
99 if (curve) | 99 if (curve) |
100 SetCurveImpl(curve.View()->Data(), curve.View()->length(), exception_state); | 100 SetCurveImpl(curve->Data(), curve->length(), exception_state); |
101 else | 101 else |
102 SetCurveImpl(nullptr, 0, exception_state); | 102 SetCurveImpl(nullptr, 0, exception_state); |
103 } | 103 } |
104 | 104 |
105 void WaveShaperNode::setCurve(const Vector<float>& curve, | 105 void WaveShaperNode::setCurve(const Vector<float>& curve, |
106 ExceptionState& exception_state) { | 106 ExceptionState& exception_state) { |
107 DCHECK(IsMainThread()); | 107 DCHECK(IsMainThread()); |
108 | 108 |
109 SetCurveImpl(curve.Data(), curve.size(), exception_state); | 109 SetCurveImpl(curve.Data(), curve.size(), exception_state); |
110 } | 110 } |
111 | 111 |
112 NotShared<DOMFloat32Array> WaveShaperNode::curve() { | 112 DOMFloat32Array* WaveShaperNode::curve() { |
113 Vector<float>* curve = GetWaveShaperProcessor()->Curve(); | 113 Vector<float>* curve = GetWaveShaperProcessor()->Curve(); |
114 if (!curve) | 114 if (!curve) |
115 return NotShared<DOMFloat32Array>(nullptr); | 115 return nullptr; |
116 | 116 |
117 unsigned size = curve->size(); | 117 unsigned size = curve->size(); |
118 RefPtr<WTF::Float32Array> new_curve = WTF::Float32Array::Create(size); | 118 RefPtr<WTF::Float32Array> new_curve = WTF::Float32Array::Create(size); |
119 | 119 |
120 memcpy(new_curve->Data(), curve->Data(), sizeof(float) * size); | 120 memcpy(new_curve->Data(), curve->Data(), sizeof(float) * size); |
121 | 121 |
122 return NotShared<DOMFloat32Array>( | 122 return DOMFloat32Array::Create(new_curve.Release()); |
123 DOMFloat32Array::Create(new_curve.Release())); | |
124 } | 123 } |
125 | 124 |
126 void WaveShaperNode::setOversample(const String& type) { | 125 void WaveShaperNode::setOversample(const String& type) { |
127 DCHECK(IsMainThread()); | 126 DCHECK(IsMainThread()); |
128 | 127 |
129 // This is to synchronize with the changes made in | 128 // This is to synchronize with the changes made in |
130 // AudioBasicProcessorNode::checkNumberOfChannelsForInput() where we can | 129 // AudioBasicProcessorNode::checkNumberOfChannelsForInput() where we can |
131 // initialize() and uninitialize(). | 130 // initialize() and uninitialize(). |
132 BaseAudioContext::AutoLocker context_locker(context()); | 131 BaseAudioContext::AutoLocker context_locker(context()); |
133 | 132 |
(...skipping 19 matching lines...) Expand all Loading... |
153 return "2x"; | 152 return "2x"; |
154 case WaveShaperProcessor::kOverSample4x: | 153 case WaveShaperProcessor::kOverSample4x: |
155 return "4x"; | 154 return "4x"; |
156 default: | 155 default: |
157 ASSERT_NOT_REACHED(); | 156 ASSERT_NOT_REACHED(); |
158 return "none"; | 157 return "none"; |
159 } | 158 } |
160 } | 159 } |
161 | 160 |
162 } // namespace blink | 161 } // namespace blink |
OLD | NEW |