OLD | NEW |
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_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 <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "media/base/channel_layout.h" |
12 #include "media/base/media_export.h" | 13 #include "media/base/media_export.h" |
13 | 14 |
14 struct AudioParameters; | |
15 | |
16 namespace base { | 15 namespace base { |
17 class SharedMemory; | 16 class SharedMemory; |
18 } | 17 } |
19 | 18 |
20 namespace media { | 19 namespace media { |
21 | 20 |
22 // For all audio functions 3 audio formats are supported: | 21 // For all audio functions 3 audio formats are supported: |
23 // 8 bits unsigned 0 to 255. | 22 // 8 bits unsigned 0 to 255. |
24 // 16 bit signed (little endian). | 23 // 16 bit signed (little endian). |
25 // 32 bit signed (little endian) | 24 // 32 bit signed (little endian) |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 // floating-point audio contained in |source| to the int16 |destination|. | 75 // floating-point audio contained in |source| to the int16 |destination|. |
77 // The floating-point data is in a canonical range of -1.0 -> +1.0. | 76 // The floating-point data is in a canonical range of -1.0 -> +1.0. |
78 // The size of the |source| vector determines the number of channels. | 77 // The size of the |source| vector determines the number of channels. |
79 // The |destination| buffer is assumed to be large enough to hold the | 78 // The |destination| buffer is assumed to be large enough to hold the |
80 // result. Thus it must be at least size: number_of_frames * source.size() | 79 // result. Thus it must be at least size: number_of_frames * source.size() |
81 MEDIA_EXPORT void InterleaveFloatToInt16(const std::vector<float*>& source, | 80 MEDIA_EXPORT void InterleaveFloatToInt16(const std::vector<float*>& source, |
82 int16* destination, | 81 int16* destination, |
83 size_t number_of_frames); | 82 size_t number_of_frames); |
84 | 83 |
85 // Returns the default audio output hardware sample-rate. | 84 // Returns the default audio output hardware sample-rate. |
86 MEDIA_EXPORT double GetAudioHardwareSampleRate(); | 85 MEDIA_EXPORT int GetAudioHardwareSampleRate(); |
87 | 86 |
88 // Returns the audio input hardware sample-rate for the specified device. | 87 // Returns the audio input hardware sample-rate for the specified device. |
89 MEDIA_EXPORT double GetAudioInputHardwareSampleRate( | 88 MEDIA_EXPORT int GetAudioInputHardwareSampleRate( |
90 const std::string& device_id); | 89 const std::string& device_id); |
91 | 90 |
92 // Returns the optimal low-latency buffer size for the audio hardware. | 91 // Returns the optimal low-latency buffer size for the audio hardware. |
93 // This is the smallest buffer size the system can comfortably render | 92 // This is the smallest buffer size the system can comfortably render |
94 // at without glitches. The buffer size is in sample-frames. | 93 // at without glitches. The buffer size is in sample-frames. |
95 MEDIA_EXPORT size_t GetAudioHardwareBufferSize(); | 94 MEDIA_EXPORT size_t GetAudioHardwareBufferSize(); |
96 | 95 |
97 // Returns the number of channels for the specified audio input device. | 96 // Returns the channel layout for the specified audio input device. |
98 MEDIA_EXPORT uint32 GetAudioInputHardwareChannelCount( | 97 MEDIA_EXPORT ChannelLayout GetAudioInputHardwareChannelLayout( |
99 const std::string& device_id); | 98 const std::string& device_id); |
100 | 99 |
101 // Functions that handle data buffer passed between processes in the shared | 100 // Functions that handle data buffer passed between processes in the shared |
102 // memory. Called on both IPC sides. | 101 // memory. Called on both IPC sides. |
103 | 102 |
104 MEDIA_EXPORT uint32 TotalSharedMemorySizeInBytes(uint32 packet_size); | 103 MEDIA_EXPORT uint32 TotalSharedMemorySizeInBytes(uint32 packet_size); |
105 MEDIA_EXPORT uint32 PacketSizeSizeInBytes(uint32 shared_memory_created_size); | 104 MEDIA_EXPORT uint32 PacketSizeSizeInBytes(uint32 shared_memory_created_size); |
106 MEDIA_EXPORT uint32 GetActualDataSizeInBytes(base::SharedMemory* shared_memory, | 105 MEDIA_EXPORT uint32 GetActualDataSizeInBytes(base::SharedMemory* shared_memory, |
107 uint32 shared_memory_size); | 106 uint32 shared_memory_size); |
108 MEDIA_EXPORT void SetActualDataSizeInBytes(base::SharedMemory* shared_memory, | 107 MEDIA_EXPORT void SetActualDataSizeInBytes(base::SharedMemory* shared_memory, |
109 uint32 shared_memory_size, | 108 uint32 shared_memory_size, |
110 uint32 actual_data_size); | 109 uint32 actual_data_size); |
111 MEDIA_EXPORT void SetUnknownDataSize(base::SharedMemory* shared_memory, | 110 MEDIA_EXPORT void SetUnknownDataSize(base::SharedMemory* shared_memory, |
112 uint32 shared_memory_size); | 111 uint32 shared_memory_size); |
113 MEDIA_EXPORT bool IsUnknownDataSize(base::SharedMemory* shared_memory, | 112 MEDIA_EXPORT bool IsUnknownDataSize(base::SharedMemory* shared_memory, |
114 uint32 shared_memory_size); | 113 uint32 shared_memory_size); |
115 | 114 |
116 #if defined(OS_WIN) | 115 #if defined(OS_WIN) |
117 | 116 |
118 // Does Windows support WASAPI? We are checking in lot of places, and | 117 // Does Windows support WASAPI? We are checking in lot of places, and |
119 // sometimes check was written incorrectly, so move into separate function. | 118 // sometimes check was written incorrectly, so move into separate function. |
120 MEDIA_EXPORT bool IsWASAPISupported(); | 119 MEDIA_EXPORT bool IsWASAPISupported(); |
121 | 120 |
122 #endif // defined(OS_WIN) | 121 #endif // defined(OS_WIN) |
123 | 122 |
124 } // namespace media | 123 } // namespace media |
125 | 124 |
126 #endif // MEDIA_AUDIO_AUDIO_UTIL_H_ | 125 #endif // MEDIA_AUDIO_AUDIO_UTIL_H_ |
OLD | NEW |