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_PARAMETERS_H_ | 5 #ifndef MEDIA_AUDIO_AUDIO_PARAMETERS_H_ |
6 #define MEDIA_AUDIO_AUDIO_PARAMETERS_H_ | 6 #define MEDIA_AUDIO_AUDIO_PARAMETERS_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
13 #include "base/time/time.h" | 13 #include "base/time/time.h" |
14 #include "media/base/audio_bus.h" | 14 #include "media/base/audio_bus.h" |
15 #include "media/base/channel_layout.h" | 15 #include "media/base/channel_layout.h" |
16 #include "media/base/media_export.h" | 16 #include "media/base/media_export.h" |
17 | 17 |
18 namespace media { | 18 namespace media { |
19 | 19 |
20 // Use a struct-in-struct approach to ensure that we can calculate the required | 20 // Use a struct-in-struct approach to ensure that we can calculate the required |
21 // size as sizeof(AudioInputBufferParameters) + #(bytes in audio buffer) without | 21 // size as sizeof(AudioInputBufferParameters) + #(bytes in audio buffer) without |
22 // using packing. Also align AudioInputBufferParameters instead of in | 22 // using packing. Also align AudioInputBufferParameters instead of in |
23 // AudioInputBuffer to be able to calculate size like so. | 23 // AudioInputBuffer to be able to calculate size like so. Use a macro for the |
| 24 // alignment value that's the same as AudioBus::kChannelAlignment, since MSVC |
| 25 // doesn't accept the latter to be used. |
24 #if defined(OS_WIN) | 26 #if defined(OS_WIN) |
25 #pragma warning(push) | 27 #pragma warning(push) |
26 #pragma warning(disable: 4324) // Disable warning for added padding. | 28 #pragma warning(disable: 4324) // Disable warning for added padding. |
27 #endif | 29 #endif |
28 struct MEDIA_EXPORT ALIGNAS(16) AudioInputBufferParameters { | 30 #define PARAMETERS_ALIGNMENT 16 |
| 31 COMPILE_ASSERT(AudioBus::kChannelAlignment == PARAMETERS_ALIGNMENT, |
| 32 AudioInputBufferParameters_alignment_not_same_as_AudioBus); |
| 33 struct MEDIA_EXPORT ALIGNAS(PARAMETERS_ALIGNMENT) AudioInputBufferParameters { |
29 double volume; | 34 double volume; |
30 uint32 size; | 35 uint32 size; |
31 uint32_t hardware_delay_bytes; | 36 uint32_t hardware_delay_bytes; |
32 uint32_t id; | 37 uint32_t id; |
33 bool key_pressed; | 38 bool key_pressed; |
34 }; | 39 }; |
| 40 #undef PARAMETERS_ALIGNMENT |
35 #if defined(OS_WIN) | 41 #if defined(OS_WIN) |
36 #pragma warning(pop) | 42 #pragma warning(pop) |
37 #endif | 43 #endif |
38 | 44 |
39 COMPILE_ASSERT( | 45 COMPILE_ASSERT( |
40 sizeof(AudioInputBufferParameters) % AudioBus::kChannelAlignment == 0, | 46 sizeof(AudioInputBufferParameters) % AudioBus::kChannelAlignment == 0, |
41 AudioInputBufferParameters_not_aligned); | 47 AudioInputBufferParameters_not_aligned); |
42 | 48 |
43 struct MEDIA_EXPORT AudioInputBuffer { | 49 struct MEDIA_EXPORT AudioInputBuffer { |
44 AudioInputBufferParameters params; | 50 AudioInputBufferParameters params; |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 if (a.sample_rate() != b.sample_rate()) | 149 if (a.sample_rate() != b.sample_rate()) |
144 return a.sample_rate() < b.sample_rate(); | 150 return a.sample_rate() < b.sample_rate(); |
145 if (a.bits_per_sample() != b.bits_per_sample()) | 151 if (a.bits_per_sample() != b.bits_per_sample()) |
146 return a.bits_per_sample() < b.bits_per_sample(); | 152 return a.bits_per_sample() < b.bits_per_sample(); |
147 return a.frames_per_buffer() < b.frames_per_buffer(); | 153 return a.frames_per_buffer() < b.frames_per_buffer(); |
148 } | 154 } |
149 | 155 |
150 } // namespace media | 156 } // namespace media |
151 | 157 |
152 #endif // MEDIA_AUDIO_AUDIO_PARAMETERS_H_ | 158 #endif // MEDIA_AUDIO_AUDIO_PARAMETERS_H_ |
OLD | NEW |