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

Side by Side Diff: services/media/audio/platform/generic/mixers/point_sampler.cc

Issue 1509323002: Mojom updates for Motown. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: sync with master 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 #include "base/logging.h" 5 #include "base/logging.h"
6 #include "services/media/audio/audio_track_impl.h" 6 #include "services/media/audio/audio_track_impl.h"
7 #include "services/media/audio/platform/generic/mixers/mixer_utils.h" 7 #include "services/media/audio/platform/generic/mixers/mixer_utils.h"
8 #include "services/media/audio/platform/generic/mixers/point_sampler.h" 8 #include "services/media/audio/platform/generic/mixers/point_sampler.h"
9 9
10 namespace mojo { 10 namespace mojo {
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 static inline MixerPtr SelectPSM(const LpcmMediaTypeDetailsPtr& src_format, 117 static inline MixerPtr SelectPSM(const LpcmMediaTypeDetailsPtr& src_format,
118 const LpcmMediaTypeDetailsPtr& dst_format) { 118 const LpcmMediaTypeDetailsPtr& dst_format) {
119 return MixerPtr(new PointSamplerImpl<DType, DChCount, SType, SChCount>()); 119 return MixerPtr(new PointSamplerImpl<DType, DChCount, SType, SChCount>());
120 } 120 }
121 121
122 template <typename DType, 122 template <typename DType,
123 size_t DChCount, 123 size_t DChCount,
124 typename SType> 124 typename SType>
125 static inline MixerPtr SelectPSM(const LpcmMediaTypeDetailsPtr& src_format, 125 static inline MixerPtr SelectPSM(const LpcmMediaTypeDetailsPtr& src_format,
126 const LpcmMediaTypeDetailsPtr& dst_format) { 126 const LpcmMediaTypeDetailsPtr& dst_format) {
127 switch (src_format->samples_per_frame) { 127 switch (src_format->channels) {
128 case 1: 128 case 1:
129 return SelectPSM<DType, DChCount, SType, 1>(src_format, dst_format); 129 return SelectPSM<DType, DChCount, SType, 1>(src_format, dst_format);
130 case 2: 130 case 2:
131 return SelectPSM<DType, DChCount, SType, 2>(src_format, dst_format); 131 return SelectPSM<DType, DChCount, SType, 2>(src_format, dst_format);
132 default: 132 default:
133 return nullptr; 133 return nullptr;
134 } 134 }
135 } 135 }
136 136
137 template <typename DType, 137 template <typename DType,
138 size_t DChCount> 138 size_t DChCount>
139 static inline MixerPtr SelectPSM(const LpcmMediaTypeDetailsPtr& src_format, 139 static inline MixerPtr SelectPSM(const LpcmMediaTypeDetailsPtr& src_format,
140 const LpcmMediaTypeDetailsPtr& dst_format) { 140 const LpcmMediaTypeDetailsPtr& dst_format) {
141 switch (src_format->sample_format) { 141 switch (src_format->sample_format) {
142 case LpcmSampleFormat::UNSIGNED_8: 142 case LpcmSampleFormat::UNSIGNED_8:
143 return SelectPSM<DType, DChCount, uint8_t>(src_format, dst_format); 143 return SelectPSM<DType, DChCount, uint8_t>(src_format, dst_format);
144 case LpcmSampleFormat::SIGNED_16: 144 case LpcmSampleFormat::SIGNED_16:
145 return SelectPSM<DType, DChCount, int16_t>(src_format, dst_format); 145 return SelectPSM<DType, DChCount, int16_t>(src_format, dst_format);
146 default: 146 default:
147 return nullptr; 147 return nullptr;
148 } 148 }
149 } 149 }
150 150
151 template <typename DType> 151 template <typename DType>
152 static inline MixerPtr SelectPSM(const LpcmMediaTypeDetailsPtr& src_format, 152 static inline MixerPtr SelectPSM(const LpcmMediaTypeDetailsPtr& src_format,
153 const LpcmMediaTypeDetailsPtr& dst_format) { 153 const LpcmMediaTypeDetailsPtr& dst_format) {
154 switch (dst_format->samples_per_frame) { 154 switch (dst_format->channels) {
155 case 1: 155 case 1:
156 return SelectPSM<DType, 1>(src_format, dst_format); 156 return SelectPSM<DType, 1>(src_format, dst_format);
157 case 2: 157 case 2:
158 return SelectPSM<DType, 2>(src_format, dst_format); 158 return SelectPSM<DType, 2>(src_format, dst_format);
159 default: 159 default:
160 return nullptr; 160 return nullptr;
161 } 161 }
162 } 162 }
163 163
164 MixerPtr PointSampler::Select(const LpcmMediaTypeDetailsPtr& src_format, 164 MixerPtr PointSampler::Select(const LpcmMediaTypeDetailsPtr& src_format,
165 const LpcmMediaTypeDetailsPtr& dst_format) { 165 const LpcmMediaTypeDetailsPtr& dst_format) {
166 switch (dst_format->sample_format) { 166 switch (dst_format->sample_format) {
167 case LpcmSampleFormat::UNSIGNED_8: 167 case LpcmSampleFormat::UNSIGNED_8:
168 return SelectPSM<uint8_t>(src_format, dst_format); 168 return SelectPSM<uint8_t>(src_format, dst_format);
169 case LpcmSampleFormat::SIGNED_16: 169 case LpcmSampleFormat::SIGNED_16:
170 return SelectPSM<int16_t>(src_format, dst_format); 170 return SelectPSM<int16_t>(src_format, dst_format);
171 default: 171 default:
172 return nullptr; 172 return nullptr;
173 } 173 }
174 } 174 }
175 175
176 } // namespace mixers 176 } // namespace mixers
177 } // namespace audio 177 } // namespace audio
178 } // namespace media 178 } // namespace media
179 } // namespace mojo 179 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698