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

Side by Side Diff: media/audio/audio_parameters.h

Issue 1538563002: Forward the number of skipped frames by the OS in audio playout. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Code review fix. git cl format. Rebase. Created 5 years 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
« no previous file with comments | « media/audio/audio_output_stream_sink.cc ('k') | media/audio/clockless_audio_sink.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_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/audio/point.h" 14 #include "media/audio/point.h"
15 #include "media/base/audio_bus.h" 15 #include "media/base/audio_bus.h"
16 #include "media/base/channel_layout.h" 16 #include "media/base/channel_layout.h"
17 #include "media/base/media_export.h" 17 #include "media/base/media_export.h"
18 18
19 namespace media { 19 namespace media {
20 20
21 // Use a struct-in-struct approach to ensure that we can calculate the required 21 // Use a struct-in-struct approach to ensure that we can calculate the required
22 // size as sizeof(AudioInputBufferParameters) + #(bytes in audio buffer) without 22 // size as sizeof(Audio{Input,Output}BufferParameters) + #(bytes in audio
23 // using packing. Also align AudioInputBufferParameters instead of in 23 // buffer) without using packing. Also align Audio{Input,Output}BufferParameters
24 // AudioInputBuffer to be able to calculate size like so. Use a macro for the 24 // instead of in Audio{Input,Output}Buffer to be able to calculate size like so.
25 // alignment value that's the same as AudioBus::kChannelAlignment, since MSVC 25 // Use a macro for the alignment value that's the same as
26 // doesn't accept the latter to be used. 26 // AudioBus::kChannelAlignment, since MSVC 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 static_assert(AudioBus::kChannelAlignment == PARAMETERS_ALIGNMENT, 32 static_assert(AudioBus::kChannelAlignment == PARAMETERS_ALIGNMENT,
33 "AudioInputBufferParameters alignment not same as AudioBus"); 33 "Audio buffer parameters struct 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_t 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 struct MEDIA_EXPORT ALIGNAS(PARAMETERS_ALIGNMENT) AudioOutputBufferParameters {
42 uint32_t frames_skipped;
43 };
41 #undef PARAMETERS_ALIGNMENT 44 #undef PARAMETERS_ALIGNMENT
42 #if defined(OS_WIN) 45 #if defined(OS_WIN)
43 #pragma warning(pop) 46 #pragma warning(pop)
44 #endif 47 #endif
45 48
46 static_assert(sizeof(AudioInputBufferParameters) % 49 static_assert(sizeof(AudioInputBufferParameters) %
47 AudioBus::kChannelAlignment == 50 AudioBus::kChannelAlignment ==
48 0, 51 0,
49 "AudioInputBufferParameters not aligned"); 52 "AudioInputBufferParameters not aligned");
53 static_assert(sizeof(AudioOutputBufferParameters) %
54 AudioBus::kChannelAlignment ==
55 0,
56 "AudioOutputBufferParameters not aligned");
50 57
51 struct MEDIA_EXPORT AudioInputBuffer { 58 struct MEDIA_EXPORT AudioInputBuffer {
52 AudioInputBufferParameters params; 59 AudioInputBufferParameters params;
53 int8 audio[1]; 60 int8 audio[1];
54 }; 61 };
62 struct MEDIA_EXPORT AudioOutputBuffer {
63 AudioOutputBufferParameters params;
64 int8 audio[1];
65 };
55 66
56 class MEDIA_EXPORT AudioParameters { 67 class MEDIA_EXPORT AudioParameters {
57 public: 68 public:
58 // TODO(miu): Rename this enum to something that correctly reflects its 69 // TODO(miu): Rename this enum to something that correctly reflects its
59 // semantics, such as "TransportScheme." 70 // semantics, such as "TransportScheme."
60 enum Format { 71 enum Format {
61 AUDIO_PCM_LINEAR = 0, // PCM is 'raw' amplitude samples. 72 AUDIO_PCM_LINEAR = 0, // PCM is 'raw' amplitude samples.
62 AUDIO_PCM_LOW_LATENCY, // Linear PCM, low latency requested. 73 AUDIO_PCM_LOW_LATENCY, // Linear PCM, low latency requested.
63 AUDIO_FAKE, // Creates a fake AudioOutputStream object. 74 AUDIO_FAKE, // Creates a fake AudioOutputStream object.
64 AUDIO_FORMAT_LAST = AUDIO_FAKE, // Only used for validation of format. 75 AUDIO_FORMAT_LAST = AUDIO_FAKE, // Only used for validation of format.
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 if (a.sample_rate() != b.sample_rate()) 204 if (a.sample_rate() != b.sample_rate())
194 return a.sample_rate() < b.sample_rate(); 205 return a.sample_rate() < b.sample_rate();
195 if (a.bits_per_sample() != b.bits_per_sample()) 206 if (a.bits_per_sample() != b.bits_per_sample())
196 return a.bits_per_sample() < b.bits_per_sample(); 207 return a.bits_per_sample() < b.bits_per_sample();
197 return a.frames_per_buffer() < b.frames_per_buffer(); 208 return a.frames_per_buffer() < b.frames_per_buffer();
198 } 209 }
199 210
200 } // namespace media 211 } // namespace media
201 212
202 #endif // MEDIA_AUDIO_AUDIO_PARAMETERS_H_ 213 #endif // MEDIA_AUDIO_AUDIO_PARAMETERS_H_
OLDNEW
« no previous file with comments | « media/audio/audio_output_stream_sink.cc ('k') | media/audio/clockless_audio_sink.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698