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

Side by Side Diff: media/base/audio_bus.h

Issue 11149006: Extend scoped_ptr to be closer to unique_ptr. Support custom deleters, and deleting arrays. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Element[] added, comments cleaned. One friend issue fixed. Created 8 years, 2 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 | Annotate | Revision Log
« base/memory/scoped_ptr.h ('K') | « base/memory/scoped_ptr_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef MEDIA_BASE_AUDIO_BUS_H_ 5 #ifndef MEDIA_BASE_AUDIO_BUS_H_
6 #define MEDIA_BASE_AUDIO_BUS_H_ 6 #define MEDIA_BASE_AUDIO_BUS_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/memory/aligned_memory.h" 10 #include "base/memory/aligned_memory.h"
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 int channels() const { return channel_data_.size(); } 84 int channels() const { return channel_data_.size(); }
85 int frames() const { return frames_; } 85 int frames() const { return frames_; }
86 void set_frames(int frames); 86 void set_frames(int frames);
87 87
88 // Helper method for zeroing out all channels of audio data. 88 // Helper method for zeroing out all channels of audio data.
89 void Zero(); 89 void Zero();
90 void ZeroFrames(int frames); 90 void ZeroFrames(int frames);
91 void ZeroFramesPartial(int start_frame, int frames); 91 void ZeroFramesPartial(int start_frame, int frames);
92 92
93 private: 93 private:
94 friend class scoped_ptr<AudioBus>; 94 friend struct base::DefaultDeleter<AudioBus>;
95 ~AudioBus(); 95 ~AudioBus();
96 96
97 AudioBus(int channels, int frames); 97 AudioBus(int channels, int frames);
98 AudioBus(int channels, int frames, float* data); 98 AudioBus(int channels, int frames, float* data);
99 AudioBus(int frames, const std::vector<float*>& channel_data); 99 AudioBus(int frames, const std::vector<float*>& channel_data);
100 explicit AudioBus(int channels); 100 explicit AudioBus(int channels);
101 101
102 // Helper method for building |channel_data_| from a block of memory. |data| 102 // Helper method for building |channel_data_| from a block of memory. |data|
103 // must be at least BlockSize() bytes in size. 103 // must be at least BlockSize() bytes in size.
104 void BuildChannelData(int channels, int aligned_frame, float* data); 104 void BuildChannelData(int channels, int aligned_frame, float* data);
105 105
106 // Contiguous block of channel memory. 106 // Contiguous block of channel memory.
107 scoped_ptr_malloc<float, base::ScopedPtrAlignedFree> data_; 107 scoped_ptr_malloc<float, base::ScopedPtrAlignedFree> data_;
108 108
109 std::vector<float*> channel_data_; 109 std::vector<float*> channel_data_;
110 int frames_; 110 int frames_;
111 111
112 // Protect SetChannelData() and set_frames() for use by CreateWrapper(). 112 // Protect SetChannelData() and set_frames() for use by CreateWrapper().
113 bool can_set_channel_data_; 113 bool can_set_channel_data_;
114 114
115 DISALLOW_COPY_AND_ASSIGN(AudioBus); 115 DISALLOW_COPY_AND_ASSIGN(AudioBus);
116 }; 116 };
117 117
118 } // namespace media 118 } // namespace media
119 119
120 #endif // MEDIA_BASE_AUDIO_BUS_H_ 120 #endif // MEDIA_BASE_AUDIO_BUS_H_
OLDNEW
« base/memory/scoped_ptr.h ('K') | « base/memory/scoped_ptr_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698