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 |
(...skipping 11 matching lines...) Expand all Loading... |
22 // size as sizeof(AudioInputBufferParameters) + #(bytes in audio buffer) without | 22 // size as sizeof(AudioInputBufferParameters) + #(bytes in audio buffer) without |
23 // using packing. Also align AudioInputBufferParameters instead of in | 23 // using packing. Also align AudioInputBufferParameters instead of in |
24 // AudioInputBuffer to be able to calculate size like so. Use a macro for the | 24 // AudioInputBuffer to be able to calculate size like so. Use a macro for the |
25 // alignment value that's the same as AudioBus::kChannelAlignment, since MSVC | 25 // alignment value that's the same as AudioBus::kChannelAlignment, since MSVC |
26 // doesn't accept the latter to be used. | 26 // doesn't accept the latter to be used. |
27 #if defined(OS_WIN) | 27 #if defined(OS_WIN) |
28 #pragma warning(push) | 28 #pragma warning(push) |
29 #pragma warning(disable: 4324) // Disable warning for added padding. | 29 #pragma warning(disable: 4324) // Disable warning for added padding. |
30 #endif | 30 #endif |
31 #define PARAMETERS_ALIGNMENT 16 | 31 #define PARAMETERS_ALIGNMENT 16 |
32 COMPILE_ASSERT(AudioBus::kChannelAlignment == PARAMETERS_ALIGNMENT, | 32 static_assert(AudioBus::kChannelAlignment == PARAMETERS_ALIGNMENT, |
33 AudioInputBufferParameters_alignment_not_same_as_AudioBus); | 33 "AudioInputBufferParameters alignment not same as AudioBus"); |
34 struct MEDIA_EXPORT ALIGNAS(PARAMETERS_ALIGNMENT) AudioInputBufferParameters { | 34 struct MEDIA_EXPORT ALIGNAS(PARAMETERS_ALIGNMENT) AudioInputBufferParameters { |
35 double volume; | 35 double volume; |
36 uint32 size; | 36 uint32 size; |
37 uint32_t hardware_delay_bytes; | 37 uint32_t hardware_delay_bytes; |
38 uint32_t id; | 38 uint32_t id; |
39 bool key_pressed; | 39 bool key_pressed; |
40 }; | 40 }; |
41 #undef PARAMETERS_ALIGNMENT | 41 #undef PARAMETERS_ALIGNMENT |
42 #if defined(OS_WIN) | 42 #if defined(OS_WIN) |
43 #pragma warning(pop) | 43 #pragma warning(pop) |
44 #endif | 44 #endif |
45 | 45 |
46 COMPILE_ASSERT( | 46 static_assert(sizeof(AudioInputBufferParameters) % |
47 sizeof(AudioInputBufferParameters) % AudioBus::kChannelAlignment == 0, | 47 AudioBus::kChannelAlignment == |
48 AudioInputBufferParameters_not_aligned); | 48 0, |
| 49 "AudioInputBufferParameters not aligned"); |
49 | 50 |
50 struct MEDIA_EXPORT AudioInputBuffer { | 51 struct MEDIA_EXPORT AudioInputBuffer { |
51 AudioInputBufferParameters params; | 52 AudioInputBufferParameters params; |
52 int8 audio[1]; | 53 int8 audio[1]; |
53 }; | 54 }; |
54 | 55 |
55 class MEDIA_EXPORT AudioParameters { | 56 class MEDIA_EXPORT AudioParameters { |
56 public: | 57 public: |
57 // TODO(miu): Rename this enum to something that correctly reflects its | 58 // TODO(miu): Rename this enum to something that correctly reflects its |
58 // semantics, such as "TransportScheme." | 59 // semantics, such as "TransportScheme." |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 if (a.sample_rate() != b.sample_rate()) | 193 if (a.sample_rate() != b.sample_rate()) |
193 return a.sample_rate() < b.sample_rate(); | 194 return a.sample_rate() < b.sample_rate(); |
194 if (a.bits_per_sample() != b.bits_per_sample()) | 195 if (a.bits_per_sample() != b.bits_per_sample()) |
195 return a.bits_per_sample() < b.bits_per_sample(); | 196 return a.bits_per_sample() < b.bits_per_sample(); |
196 return a.frames_per_buffer() < b.frames_per_buffer(); | 197 return a.frames_per_buffer() < b.frames_per_buffer(); |
197 } | 198 } |
198 | 199 |
199 } // namespace media | 200 } // namespace media |
200 | 201 |
201 #endif // MEDIA_AUDIO_AUDIO_PARAMETERS_H_ | 202 #endif // MEDIA_AUDIO_AUDIO_PARAMETERS_H_ |
OLD | NEW |