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

Side by Side Diff: third_party/WebKit/Source/platform/audio/AudioChannel.h

Issue 2050123002: Remove OwnPtr from Blink. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: First attempt to land. Created 4 years, 6 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) 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 14 matching lines...) Expand all
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */ 27 */
28 28
29 #ifndef AudioChannel_h 29 #ifndef AudioChannel_h
30 #define AudioChannel_h 30 #define AudioChannel_h
31 31
32 #include "platform/PlatformExport.h" 32 #include "platform/PlatformExport.h"
33 #include "platform/audio/AudioArray.h" 33 #include "platform/audio/AudioArray.h"
34 #include "wtf/Allocator.h" 34 #include "wtf/Allocator.h"
35 #include "wtf/PassOwnPtr.h" 35 #include "wtf/PtrUtil.h"
36 #include <memory>
36 37
37 namespace blink { 38 namespace blink {
38 39
39 // An AudioChannel represents a buffer of non-interleaved floating-point audio s amples. 40 // An AudioChannel represents a buffer of non-interleaved floating-point audio s amples.
40 // The PCM samples are normally assumed to be in a nominal range -1.0 -> +1.0 41 // The PCM samples are normally assumed to be in a nominal range -1.0 -> +1.0
41 class PLATFORM_EXPORT AudioChannel { 42 class PLATFORM_EXPORT AudioChannel {
42 USING_FAST_MALLOC(AudioChannel); 43 USING_FAST_MALLOC(AudioChannel);
43 WTF_MAKE_NONCOPYABLE(AudioChannel); 44 WTF_MAKE_NONCOPYABLE(AudioChannel);
44 public: 45 public:
45 // Memory can be externally referenced, or can be internally allocated with an AudioFloatArray. 46 // Memory can be externally referenced, or can be internally allocated with an AudioFloatArray.
46 47
47 // Reference an external buffer. 48 // Reference an external buffer.
48 AudioChannel(float* storage, size_t length) 49 AudioChannel(float* storage, size_t length)
49 : m_length(length) 50 : m_length(length)
50 , m_rawPointer(storage) 51 , m_rawPointer(storage)
51 , m_silent(false) 52 , m_silent(false)
52 { 53 {
53 } 54 }
54 55
55 // Manage storage for us. 56 // Manage storage for us.
56 explicit AudioChannel(size_t length) 57 explicit AudioChannel(size_t length)
57 : m_length(length) 58 : m_length(length)
58 , m_rawPointer(nullptr) 59 , m_rawPointer(nullptr)
59 , m_silent(true) 60 , m_silent(true)
60 { 61 {
61 m_memBuffer = adoptPtr(new AudioFloatArray(length)); 62 m_memBuffer = wrapUnique(new AudioFloatArray(length));
62 } 63 }
63 64
64 // A "blank" audio channel -- must call set() before it's useful... 65 // A "blank" audio channel -- must call set() before it's useful...
65 AudioChannel() 66 AudioChannel()
66 : m_length(0) 67 : m_length(0)
67 , m_rawPointer(nullptr) 68 , m_rawPointer(nullptr)
68 , m_silent(true) 69 , m_silent(true)
69 { 70 {
70 } 71 }
71 72
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 // Sums (with unity gain) from the source channel. 127 // Sums (with unity gain) from the source channel.
127 void sumFrom(const AudioChannel* sourceChannel); 128 void sumFrom(const AudioChannel* sourceChannel);
128 129
129 // Returns maximum absolute value (useful for normalization). 130 // Returns maximum absolute value (useful for normalization).
130 float maxAbsValue() const; 131 float maxAbsValue() const;
131 132
132 private: 133 private:
133 size_t m_length; 134 size_t m_length;
134 135
135 float* m_rawPointer; 136 float* m_rawPointer;
136 OwnPtr<AudioFloatArray> m_memBuffer; 137 std::unique_ptr<AudioFloatArray> m_memBuffer;
137 bool m_silent; 138 bool m_silent;
138 }; 139 };
139 140
140 } // namespace blink 141 } // namespace blink
141 142
142 #endif // AudioChannel_h 143 #endif // AudioChannel_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/audio/AudioBus.cpp ('k') | third_party/WebKit/Source/platform/audio/AudioChannel.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698