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

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

Issue 10830268: Allow audio system to handle synchronized low-latency audio I/O (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 3 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
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 27 matching lines...) Expand all
38 38
39 // Creates a new AudioBus by wrapping an existing block of memory. Block must 39 // Creates a new AudioBus by wrapping an existing block of memory. Block must
40 // be at least CalculateMemorySize() bytes in size. |data| must outlive the 40 // be at least CalculateMemorySize() bytes in size. |data| must outlive the
41 // returned AudioBus. |data| must be aligned by kChannelAlignment. 41 // returned AudioBus. |data| must be aligned by kChannelAlignment.
42 static scoped_ptr<AudioBus> WrapMemory(int channels, int frames, void* data); 42 static scoped_ptr<AudioBus> WrapMemory(int channels, int frames, void* data);
43 static scoped_ptr<AudioBus> WrapMemory(const AudioParameters& params, 43 static scoped_ptr<AudioBus> WrapMemory(const AudioParameters& params,
44 void* data); 44 void* data);
45 // Returns the required memory size to use the WrapMemory() method. 45 // Returns the required memory size to use the WrapMemory() method.
46 static int CalculateMemorySize(const AudioParameters& params); 46 static int CalculateMemorySize(const AudioParameters& params);
47 47
48 // Calculates the required size for an AudioBus with the given params, sets
49 // |aligned_frames| to the actual frame length of each channel array.
50 static int CalculateMemorySizeFromChannels(int channels, int frames,
51 int* aligned_frames);
DaleCurtis 2012/09/11 09:44:39 I'd prefer this to be just CalculateMemorySize(int
scherkus (not reviewing) 2012/09/11 12:13:00 Perhaps we need an internal impl w/ |aligned_frame
DaleCurtis 2012/09/11 12:22:23 Yes, that's what I was thinking.
52
48 // Helper methods for converting an AudioBus from and to interleaved integer 53 // Helper methods for converting an AudioBus from and to interleaved integer
49 // data. Expects interleaving to be [ch0, ch1, ..., chN, ch0, ch1, ...] with 54 // data. Expects interleaving to be [ch0, ch1, ..., chN, ch0, ch1, ...] with
50 // |bytes_per_sample| per value. Values are scaled and bias corrected during 55 // |bytes_per_sample| per value. Values are scaled and bias corrected during
51 // conversion. ToInterleaved() will also clip values to format range. 56 // conversion. ToInterleaved() will also clip values to format range.
52 // Handles uint8, int16, and int32 currently. FromInterleaved() will zero out 57 // Handles uint8, int16, and int32 currently. FromInterleaved() will zero out
53 // any unfilled frames when |frames| is less than frames(). 58 // any unfilled frames when |frames| is less than frames().
54 void FromInterleaved(const void* source, int frames, int bytes_per_sample); 59 void FromInterleaved(const void* source, int frames, int bytes_per_sample);
55 void ToInterleaved(int frames, int bytes_per_sample, void* dest) const; 60 void ToInterleaved(int frames, int bytes_per_sample, void* dest) const;
56 61
57 // Similar to FromInterleaved() above, but meant for streaming sources. Does 62 // Similar to FromInterleaved() above, but meant for streaming sources. Does
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 101
97 std::vector<float*> channel_data_; 102 std::vector<float*> channel_data_;
98 int frames_; 103 int frames_;
99 104
100 DISALLOW_COPY_AND_ASSIGN(AudioBus); 105 DISALLOW_COPY_AND_ASSIGN(AudioBus);
101 }; 106 };
102 107
103 } // namespace media 108 } // namespace media
104 109
105 #endif // MEDIA_BASE_AUDIO_BUS_H_ 110 #endif // MEDIA_BASE_AUDIO_BUS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698