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

Side by Side Diff: third_party/WebKit/Source/modules/webaudio/WaveShaperNode.cpp

Issue 2223613002: WaveShaperNode should copy its curve. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address review comments. Created 4 years, 4 months 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 unified diff | Download patch
OLDNEW
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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 curve->length(), 69 curve->length(),
70 2)); 70 2));
71 return; 71 return;
72 } 72 }
73 73
74 getWaveShaperProcessor()->setCurve(curve); 74 getWaveShaperProcessor()->setCurve(curve);
75 } 75 }
76 76
77 DOMFloat32Array* WaveShaperNode::curve() 77 DOMFloat32Array* WaveShaperNode::curve()
78 { 78 {
79 return getWaveShaperProcessor()->curve(); 79 Vector<float>* curve = getWaveShaperProcessor()->curve();
80 if (!curve)
81 return nullptr;
82
83 unsigned size = curve->size();
84 RefPtr<WTF::Float32Array> newCurve = WTF::Float32Array::create(size);
85
86 memcpy(newCurve->data(), curve->data(), sizeof(float) * size);
87
88 return DOMFloat32Array::create(newCurve.release());
80 } 89 }
81 90
82 void WaveShaperNode::setOversample(const String& type) 91 void WaveShaperNode::setOversample(const String& type)
83 { 92 {
84 ASSERT(isMainThread()); 93 ASSERT(isMainThread());
85 94
86 // This is to synchronize with the changes made in 95 // This is to synchronize with the changes made in
87 // AudioBasicProcessorNode::checkNumberOfChannelsForInput() where we can 96 // AudioBasicProcessorNode::checkNumberOfChannelsForInput() where we can
88 // initialize() and uninitialize(). 97 // initialize() and uninitialize().
89 BaseAudioContext::AutoLocker contextLocker(context()); 98 BaseAudioContext::AutoLocker contextLocker(context());
(...skipping 19 matching lines...) Expand all
109 case WaveShaperProcessor::OverSample4x: 118 case WaveShaperProcessor::OverSample4x:
110 return "4x"; 119 return "4x";
111 default: 120 default:
112 ASSERT_NOT_REACHED(); 121 ASSERT_NOT_REACHED();
113 return "none"; 122 return "none";
114 } 123 }
115 } 124 }
116 125
117 } // namespace blink 126 } // namespace blink
118 127
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698