| OLD | NEW |
| 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 <algorithm> | 5 #include <algorithm> |
| 6 #include <limits> | 6 #include <limits> |
| 7 | 7 |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "services/media/audio/platform/generic/mixers/linear_sampler.h" | 9 #include "services/media/audio/platform/generic/mixers/linear_sampler.h" |
| 10 #include "services/media/audio/platform/generic/mixers/mixer_utils.h" | 10 #include "services/media/audio/platform/generic/mixers/mixer_utils.h" |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 src, frac_src_frames, frac_src_offset, | 218 src, frac_src_frames, frac_src_offset, |
| 219 frac_step_size, amplitude_scale); | 219 frac_step_size, amplitude_scale); |
| 220 } | 220 } |
| 221 } | 221 } |
| 222 | 222 |
| 223 // Templates used to expand all of the different combinations of the possible | 223 // Templates used to expand all of the different combinations of the possible |
| 224 // Linear Sampler Mixer configurations. | 224 // Linear Sampler Mixer configurations. |
| 225 template <size_t DChCount, | 225 template <size_t DChCount, |
| 226 typename SType, | 226 typename SType, |
| 227 size_t SChCount> | 227 size_t SChCount> |
| 228 static inline MixerPtr SelectLSM(const LpcmMediaTypeDetailsPtr& src_format, | 228 static inline MixerPtr SelectLSM(const AudioMediaTypeDetailsPtr& src_format, |
| 229 const LpcmMediaTypeDetailsPtr& dst_format) { | 229 const AudioMediaTypeDetailsPtr& dst_format) { |
| 230 return MixerPtr(new LinearSamplerImpl<DChCount, SType, SChCount>()); | 230 return MixerPtr(new LinearSamplerImpl<DChCount, SType, SChCount>()); |
| 231 } | 231 } |
| 232 | 232 |
| 233 template <size_t DChCount, | 233 template <size_t DChCount, |
| 234 typename SType> | 234 typename SType> |
| 235 static inline MixerPtr SelectLSM(const LpcmMediaTypeDetailsPtr& src_format, | 235 static inline MixerPtr SelectLSM(const AudioMediaTypeDetailsPtr& src_format, |
| 236 const LpcmMediaTypeDetailsPtr& dst_format) { | 236 const AudioMediaTypeDetailsPtr& dst_format) { |
| 237 switch (src_format->channels) { | 237 switch (src_format->channels) { |
| 238 case 1: | 238 case 1: |
| 239 return SelectLSM<DChCount, SType, 1>(src_format, dst_format); | 239 return SelectLSM<DChCount, SType, 1>(src_format, dst_format); |
| 240 case 2: | 240 case 2: |
| 241 return SelectLSM<DChCount, SType, 2>(src_format, dst_format); | 241 return SelectLSM<DChCount, SType, 2>(src_format, dst_format); |
| 242 default: | 242 default: |
| 243 return nullptr; | 243 return nullptr; |
| 244 } | 244 } |
| 245 } | 245 } |
| 246 | 246 |
| 247 template <size_t DChCount> | 247 template <size_t DChCount> |
| 248 static inline MixerPtr SelectLSM(const LpcmMediaTypeDetailsPtr& src_format, | 248 static inline MixerPtr SelectLSM(const AudioMediaTypeDetailsPtr& src_format, |
| 249 const LpcmMediaTypeDetailsPtr& dst_format) { | 249 const AudioMediaTypeDetailsPtr& dst_format) { |
| 250 switch (src_format->sample_format) { | 250 switch (src_format->sample_format) { |
| 251 case LpcmSampleFormat::UNSIGNED_8: | 251 case AudioSampleFormat::UNSIGNED_8: |
| 252 return SelectLSM<DChCount, uint8_t>(src_format, dst_format); | 252 return SelectLSM<DChCount, uint8_t>(src_format, dst_format); |
| 253 case LpcmSampleFormat::SIGNED_16: | 253 case AudioSampleFormat::SIGNED_16: |
| 254 return SelectLSM<DChCount, int16_t>(src_format, dst_format); | 254 return SelectLSM<DChCount, int16_t>(src_format, dst_format); |
| 255 default: | 255 default: |
| 256 return nullptr; | 256 return nullptr; |
| 257 } | 257 } |
| 258 } | 258 } |
| 259 | 259 |
| 260 MixerPtr LinearSampler::Select(const LpcmMediaTypeDetailsPtr& src_format, | 260 MixerPtr LinearSampler::Select(const AudioMediaTypeDetailsPtr& src_format, |
| 261 const LpcmMediaTypeDetailsPtr& dst_format) { | 261 const AudioMediaTypeDetailsPtr& dst_format) { |
| 262 switch (dst_format->channels) { | 262 switch (dst_format->channels) { |
| 263 case 1: | 263 case 1: |
| 264 return SelectLSM<1>(src_format, dst_format); | 264 return SelectLSM<1>(src_format, dst_format); |
| 265 case 2: | 265 case 2: |
| 266 return SelectLSM<2>(src_format, dst_format); | 266 return SelectLSM<2>(src_format, dst_format); |
| 267 default: | 267 default: |
| 268 return nullptr; | 268 return nullptr; |
| 269 } | 269 } |
| 270 } | 270 } |
| 271 | 271 |
| 272 } // namespace mixers | 272 } // namespace mixers |
| 273 } // namespace audio | 273 } // namespace audio |
| 274 } // namespace media | 274 } // namespace media |
| 275 } // namespace mojo | 275 } // namespace mojo |
| OLD | NEW |