OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_AUDIO_AUDIO_UTIL_H_ | 5 #ifndef MEDIA_AUDIO_AUDIO_UTIL_H_ |
6 #define MEDIA_AUDIO_AUDIO_UTIL_H_ | 6 #define MEDIA_AUDIO_AUDIO_UTIL_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 int channels, | 55 int channels, |
56 int bytes_per_sample, | 56 int bytes_per_sample, |
57 float volume); | 57 float volume); |
58 | 58 |
59 // DeinterleaveAudioChannel() takes interleaved audio buffer |source| | 59 // DeinterleaveAudioChannel() takes interleaved audio buffer |source| |
60 // of the given |sample_fmt| and |number_of_channels| and extracts | 60 // of the given |sample_fmt| and |number_of_channels| and extracts |
61 // |number_of_frames| data for the given |channel_index| and | 61 // |number_of_frames| data for the given |channel_index| and |
62 // puts it in the floating point |destination|. | 62 // puts it in the floating point |destination|. |
63 // It returns |true| on success, or |false| if the |sample_fmt| is | 63 // It returns |true| on success, or |false| if the |sample_fmt| is |
64 // not recognized. | 64 // not recognized. |
65 bool DeinterleaveAudioChannel(void* source, | 65 MEDIA_EXPORT bool DeinterleaveAudioChannel(void* source, |
66 float* destination, | 66 float* destination, |
67 int channels, | 67 int channels, |
68 int channel_index, | 68 int channel_index, |
69 int bytes_per_sample, | 69 int bytes_per_sample, |
70 size_t number_of_frames); | 70 size_t number_of_frames); |
71 | 71 |
72 // InterleaveFloatToInt16 scales, clips, and interleaves the planar | 72 // InterleaveFloatToInt16 scales, clips, and interleaves the planar |
73 // floating-point audio contained in |source| to the int16 |destination|. | 73 // floating-point audio contained in |source| to the int16 |destination|. |
74 // The floating-point data is in a canonical range of -1.0 -> +1.0. | 74 // The floating-point data is in a canonical range of -1.0 -> +1.0. |
75 // The size of the |source| vector determines the number of channels. | 75 // The size of the |source| vector determines the number of channels. |
76 // The |destination| buffer is assumed to be large enough to hold the | 76 // The |destination| buffer is assumed to be large enough to hold the |
77 // result. Thus it must be at least size: number_of_frames * source.size() | 77 // result. Thus it must be at least size: number_of_frames * source.size() |
78 MEDIA_EXPORT void InterleaveFloatToInt16(const std::vector<float*>& source, | 78 MEDIA_EXPORT void InterleaveFloatToInt16(const std::vector<float*>& source, |
79 int16* destination, | 79 int16* destination, |
80 size_t number_of_frames); | 80 size_t number_of_frames); |
81 | 81 |
82 // Returns the default audio hardware sample-rate. | 82 // Returns the default audio hardware sample-rate. |
83 MEDIA_EXPORT double GetAudioHardwareSampleRate(); | 83 MEDIA_EXPORT double GetAudioHardwareSampleRate(); |
84 | 84 |
85 // Functions that handle data buffer passed between processes in the shared | 85 // Functions that handle data buffer passed between processes in the shared |
86 // memory. Called on both IPC sides. | 86 // memory. Called on both IPC sides. |
87 | 87 |
88 MEDIA_EXPORT uint32 TotalSharedMemorySizeInBytes(uint32 packet_size); | 88 MEDIA_EXPORT uint32 TotalSharedMemorySizeInBytes(uint32 packet_size); |
89 MEDIA_EXPORT uint32 PacketSizeSizeInBytes(uint32 shared_memory_created_size); | 89 MEDIA_EXPORT uint32 PacketSizeSizeInBytes(uint32 shared_memory_created_size); |
90 MEDIA_EXPORT uint32 GetActualDataSizeInBytes(base::SharedMemory* shared_memory, | 90 MEDIA_EXPORT uint32 GetActualDataSizeInBytes(base::SharedMemory* shared_memory, |
91 uint32 shared_memory_size); | 91 uint32 shared_memory_size); |
92 MEDIA_EXPORT void SetActualDataSizeInBytes(base::SharedMemory* shared_memory, | 92 MEDIA_EXPORT void SetActualDataSizeInBytes(base::SharedMemory* shared_memory, |
93 uint32 shared_memory_size, | 93 uint32 shared_memory_size, |
94 uint32 actual_data_size); | 94 uint32 actual_data_size); |
95 | 95 |
96 } // namespace media | 96 } // namespace media |
97 | 97 |
98 #endif // MEDIA_AUDIO_AUDIO_UTIL_H_ | 98 #endif // MEDIA_AUDIO_AUDIO_UTIL_H_ |
OLD | NEW |